2 // System.Windows.Forms Demo2 app
5 // Joel Basson (jstrike@mweb.co.za)
6 // Philip Van Hoof (me@freax.org)
11 using System
.Windows
.Forms
;
16 public class GtkForm
: System
.Windows
.Forms
.Form
18 private Button button1
= new Button();
19 private Button button2
= new Button();
20 private ColorDialog color1
= new ColorDialog();
21 private ComboBox combo1
= new ComboBox();
22 private MainMenu mainMenu1
= new MainMenu();
23 private MenuItem menuItem1
= new MenuItem();
24 private MenuItem menuItem2
= new MenuItem();
25 private MenuItem menuItem3
= new MenuItem();
26 private MenuItem menuItem4
= new MenuItem();
27 private MenuItem menuItem5
= new MenuItem();
29 private ListBox lb
= new ListBox();
31 private StatusBar statusBar1
= new StatusBar();
32 private StatusBar statusBar2
= new StatusBar();
33 private StatusBar statusBar3
= new StatusBar();
35 private void InitializeWidgets()
37 button1
.Location
= new Point(100, 28);
38 button1
.Name
= "button1";
39 button1
.Size
= new Size(128, 44);
40 button1
.Text
= "Color";
41 button1
.Click
+= new EventHandler(this.button1_Click
);
43 this.statusBar1
.Location
= new System
.Drawing
.Point(0, 251);
44 this.statusBar1
.Name
= "statusBar1";
45 this.statusBar1
.Size
= new System
.Drawing
.Size(292, 22);
46 this.statusBar1
.TabIndex
= 0;
47 this.statusBar1
.Text
= "statusBar1";
49 this.statusBar2
.Location
= new System
.Drawing
.Point(0, 240);
50 this.statusBar2
.Name
= "statusBar2";
51 this.statusBar2
.Size
= new System
.Drawing
.Size(292, 22);
52 this.statusBar2
.TabIndex
= 0;
53 this.statusBar2
.Text
= "statusBar2";
55 this.statusBar3
.Location
= new System
.Drawing
.Point(0, 251);
56 this.statusBar3
.Name
= "statusBar3";
57 this.statusBar3
.Size
= new System
.Drawing
.Size(292, 22);
58 this.statusBar3
.TabIndex
= 0;
59 this.statusBar3
.Text
= "statusBar3";
61 button1
.Location
= new Point(100, 28);
62 button1
.Name
= "button1";
63 button1
.Size
= new Size(128, 44);
64 button1
.Text
= "Color";
65 button1
.Click
+= new EventHandler(this.button1_Click
);
67 button1
.Enabled
= true;
69 button2
.Location
= new Point(100, 80);
70 button2
.Name
= "button2";
71 button2
.Size
= new Size(128, 44);
72 button2
.Text
= "Add to ComboBox";
73 button2
.Click
+= new EventHandler(this.button2_Click
);
75 button2
.Enabled
= true;
77 this.lb
.Location
= new System
.Drawing
.Point(280, 28);
78 this.lb
.Size
= new System
.Drawing
.Size(200, 200);
80 menuItem1
.Text
= "File";
81 menuItem2
.Text
= "Exit";
82 menuItem2
.Click
+= new EventHandler(this.menuItem2_Click
);
83 menuItem3
.Text
= "Edit";
84 menuItem4
.Text
= "&Stop";
85 menuItem4
.Click
+= new EventHandler(this.menuItem4_Click
);
86 menuItem4
.Shortcut
= Shortcut
.CtrlS
;
87 menuItem5
.Text
= "S&tart";
88 menuItem5
.Checked
= true;
89 menuItem1
.MenuItems
.Add(menuItem2
);
90 menuItem3
.MenuItems
.AddRange(new System
.Windows
.Forms
.MenuItem
[] {menuItem4
,
92 mainMenu1
.MenuItems
.AddRange(new System
.Windows
.Forms
.MenuItem
[] {menuItem1
,
95 combo1
.Location
= new Point(100, 150);
96 this.combo1
.Items
.AddRange(new object[] {"Item 1",
102 this.Controls
.AddRange(new System
.Windows
.Forms
.Control
[] {
112 this.Size
= new Size(512, 250);
113 this.Menu
= mainMenu1
;
115 //this.button1.Controls.Add (this.statusBar3);
123 private void button1_Click(object sender
, EventArgs e
){
127 private void button2_Click(object sender
, EventArgs e
){
128 combo1
.BeginUpdate();
130 for (int i
= 1; i
< 5; i
++) {
131 combo1
.Items
.Add("Joel");
132 lb
.Items
.Add("MyItems");
137 private void menuItem2_Click (object sender
, EventArgs e
){
138 MessageBox
.Show("You clicked Exit");
141 private void menuItem4_Click(object sender
, EventArgs e
){
142 MessageBox
.Show("You clicked Stop");
150 public static void Main()
152 GtkForm form1
= new GtkForm ();
153 form1
.Text
= "System.Windows.Forms at work!";
154 Application
.Run(form1
);