I'm writing a windows mobile app that uses dynamiclly created checkboxes. I'm having trouble getting the checked status.
When I press the button, the checkboxes are created correctly, and when I check them the font changes to strikeout as it should. However, I need to be able to determine when the checkbox is checked and unchecked.
Code:
public void Add_CheckBox(String CBText)
{
CheckBox MyCheckbox = new CheckBox();
MyCheckbox.Location = new System.Drawing.Point(4, CB_Row * 20);
MyCheckbox.Name = "MycheckBox" + CB_Row;
MyCheckbox.Text = CBText;
MyCheckbox.Font = NormalFont;
MyCheckbox.Size = new System.Drawing.Size(CBText.Length * 12, 20);
MyCheckbox.TabIndex = CB_Row;
this.Controls.Add(MyCheckbox);
MyCheckbox.Click += new EventHandler(MyCheckbox_Click);
CB_Row = CB_Row + 1;
}
private void button1_Click(object sender, EventArgs e)
{
Add_CheckBox("TextBox " + CB_Row);
}
private void MyCheckbox_Click(object sender, EventArgs e)
{
((System.Windows.Forms.Control)(sender)).Font = StrikeoutFont;
}
Comment