My application is running unstable because I have to many checkboxes in one form. I heard from some source, that I should try to populate the checkboxes in a CheckedListBox. But I dont know how i can realize that. Among I wanna show you my solution with CheckBox.
Can anyone show me how I can populate this with a CheckedListBox?
for (int i = 1; i <= maxTask; i++)
{
Label labelTasks = new Label();
labelTasks.Text = "A" + i;
labelTasks.Width = 28;
labelTasks.Height = 13;
labelTasks.Location = new Point(boundX_Label, boundY_Label);
boundX_Label += 26;
panel.Controls.Add(labelTasks);
CheckBox checkBox = new CheckBox();
checkBox.Name = String.Format("checkboxTask{0}", i);
checkBox.GotFocus += checkBox_GotFocus;
checkBox.LostFocus += checkBox_LostFocus;
checkBox.Text = "";
checkBox.Width = 20;
checkBox.Height = 15;
checkBox.Location = new Point(boundX_ChkBox, boundY_ChkBox);
boundX_ChkBox += 26;
checkBox.CheckedChanged += new EventHandler(checkBox_CheckedChanged);
panel.Controls.Add(checkBox);
}
This code will populate a row of checkboxes like showing among. My application have around 200 of this checkbox rows.
Aucun commentaire:
Enregistrer un commentaire