Implement CheckBoxes in Listbox?
-
Hi friends, Plz suggest me how can i implement checkboxes in listbox in Windows forms application. I want to use checkboxes to select items from the listbox. If possible, plz send me the code..... Thanks, Sandeep +919891027854
-
Hi friends, Plz suggest me how can i implement checkboxes in listbox in Windows forms application. I want to use checkboxes to select items from the listbox. If possible, plz send me the code..... Thanks, Sandeep +919891027854
Look for a Windows forms' control called
CheckedListBox
in your toolbox instead Regards, Polis Can you practice what you teach? -
Look for a Windows forms' control called
CheckedListBox
in your toolbox instead Regards, Polis Can you practice what you teach?Thanks for ur reply. Have u any sample code in which u catch the checkboxes that are selected from the CheckedListBox? I want to select multiple values from tha CheckedListBox.... Regards, Sandeep +919891027854
-
Thanks for ur reply. Have u any sample code in which u catch the checkboxes that are selected from the CheckedListBox? I want to select multiple values from tha CheckedListBox.... Regards, Sandeep +919891027854
Yes, take a look below at the following self-explanatory code chunk. First I add three items into the
checkedListBox
, and then I get the text of the selected ones by looping through each one of them:string
checkedItems
= "";// Add a few items into the checkedListBox control
this.checkedListBox1.Items.Add("Item 1", CheckState.Checked);
this.checkedListBox1.Items.Add("Item 2", CheckState.Indeterminate);
this.checkedListBox1.Items.Add("Item 3", CheckState.Unchecked);// Retrieve the selected items in a string
for (int i = 0; i < this.checkedListBox1.Items.Count; i++)
{
if (this.checkedListBox1.GetItemChecked(i))
checkedItems
+= this.checkedListBox1.Items[i].ToString() + "\n";
}MessageBox.Show(
checkedItems
);Regards, Polis Can you practice what you teach?