C# Simplified, part 7: Working with WinForm Controls - Working with Checkboxes
(Page 2 of 6 )
Checkboxes enable you to select more than one item at a time. This control is widely used in all applications. The moment you click on an item, a tick mark appears on the control. The tick mark will disappear if you click it again. Listing 7.2 illustrates this control:
Listing 7.2
001: using System;
002: using System.Drawing;
003: using System.Windows.Forms;
004:
005: public class MyCheckbox:Form
006: {
007: CheckBox c1 = new CheckBox();
008: CheckBox c2 = new CheckBox();
009: CheckBox c3 = new CheckBox();
010:
011: MyCheckbox()
012: {
013: c1.Text = "Football";
014: c2.Text = "BasketBall";
015: c3.Text = "Swimming";
016:
017: c1.Location = new Point(50,40);
018: c2.Location = new Point(50,60);
019: c3.Location = new Point(50,80);
020:
021: this.Controls.Add(c1);
022: this.Controls.Add(c2);
023: this.Controls.Add(c3);
024:
025: this.Text = "CheckBox Control Demo";
026: }
027:
028: public static void Main()
029: {
030: MyCheckbox mychk = new MyCheckbox();
031: Application.Run(mychk);
032: }
033: }
Output

Figure 7.2
Next: Working with RadioButtons >>
More C# Articles
More By Anand Narayanaswamy