I have a programmatically created checkedListBox that has several options. What I want to be able to do is, when a user 'checks' an item in the checkedListBox, programmatically create a TextBox based on what was checked 'live' (without having to click another button or anything to create the TextBox). (Example) The text box should also disappear if the option is unchecked.
So far here is what I have:
private void rangetypecheckedlistbox_ItemChecked(object sender, ItemCheckEventArgs e)
{
List<string> checkedrangetypes = new List<string>();
foreach (object item in ((CheckedListBox)panel_corebonusbonuses.Controls["comboBox_corebonusbonuses_range_type_input"]).CheckedItems)
{
checkedrangetypes.Add(item.ToString());
}
foreach (string item in checkedrangetypes)
{
Label newdynamicvallabel = new Label();
newdynamicvallabel.Size = new Size(201, 20);
newdynamicvallabel.Name = "dynamic_label" + item;
newdynamicvallabel.Location = new Point(100, 130);
newdynamicvallabel.Text = item.ToUpper() + " VALUE";
//Create range_type textbox.
TextBox newdynamicvaltext = new TextBox();
newdynamicvaltext.Size = new Size(272, 28);
newdynamicvaltext.Name = "dynamic_textbox_" + item + "_input";
newdynamicvaltext.Location = new Point(381, 127);
newdynamicvaltext.BorderStyle = BorderStyle.FixedSingle;
panel_corebonusbonuses.Controls.Add(newdynamicvallabel);
panel_corebonusbonuses.Controls.Add(newdynamicvaltext);
checkedrangetypes.Remove(item);
}
}
But it doesn't seem to create the textbox when I select a new item. I am relatively new to c# and winforms and this is my first app in the language, so any help and explanation would be greatly appreciated!