Lesson 2: Hello Gtk# with Form
.NET,
C#,
Gnome,
Gtk#,
How-to,
Linux,
Mandriva,
Programming,
Tutorial
Add comments
Download Project
We do the same thing with Lesson 1 but this time we use form for better GUI.
This is the source code, self-explained fully-commented.
using System;
using Gtk;
public class Lesson_2
{
public static void Main() {
Application.Init();
// create a window
Window window = new Window("Lesson 2: Say hello with Gtk# Form");
window.Resize(400, 40);
// create a label
Label label = new Label("Hello Gtk# .NET");
// add label to the form
window.Add(label);
// show form and its widgets
window.ShowAll();
Application.Run();
}
}
Build and run, this is result:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDvxQUlPi3HH26JOFaJWPpdiHxaB0Yon58pK_Aqr719EzP0HdVgz8XB5Y0pYHTiXNKY9nW9mVte9UjqtcLPliBAkMK45LRSWJhWT4wI8pkCH4X14hvYuvHQ_-5MQtwBRpWG2G7uLhRPhhI/s400/lesson_2.png)
Have fun!