i have the followng code that loads a table of Roles to the CheckedListBox:
C# |
When i check the first item in the CheckedListBox, all the other items must be checked, how do i do that?
cheers
C# |
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Manikavelu VelayuthamRank #413 · 6K reputationPosted Sep 1, 2010, 11:04 PM EDT
1. Through the .NET code
2, Through Javascript - > if the application is web based.
May i know what application you are developing, web or windows ?
petre ricardo155 reputationPosted Sep 1, 2010, 11:23 PM EDT
anyway i have my best to copy-paste the code but displasy like crud.
hi manik, its a windows application : )
here an image of the code:
cheers
Manikavelu VelayuthamRank #413 · 6K reputationPosted Sep 1, 2010, 11:35 PM EDT
{
string item = inputCheckedListBox.SelectedItem.ToString();
if (item =="your first choice")
{
for(int i = 0; i < CheckedListBox1.Items.Count; i++)
{
CheckedListBox1.SetItemChecked(i, true);
}
}
}
hope this code helps u
dont forget to mark this post as answered or mark this post as good post if you really like it
petre ricardo155 reputationPosted Sep 1, 2010, 11:54 PM EDT
1. inputCheckedListBox.SelectedItem.ToString(); does not get the item becuase its a DataRowView therefore it never enters the for loop
2. when i do change as below image it goes to an infinite loop:
How do i fix this?
thanks
Manikavelu VelayuthamRank #413 · 6K reputationPosted Sep 2, 2010, 12:03 AM EDT
just try to find out the first item in checked list box
make the first item in the listbox like "Check All", after that check it out in the following code and process the asusual way.
if (CheckedListbox1[0].Checked == true)
, then make all the items to be checked. Surely it will work.