CheckListBox select single item...  
Author Message
IamHuM





PostPosted: Visual C# General, CheckListBox select single item... Top

hi..

How i can select single item in a CheckListBox...

I want to enable it or disable a single item or i want to check it or uncheck it...

Thanks in adavance,
Vinay


Visual C#4  
 
 
RizwanSharp





PostPosted: Visual C# General, CheckListBox select single item... Top

I'm not sure about enabling and disabling individual item and doubt its even supported but You can check and uncheck programatically using this function:

checkedListBox1.SetItemChecked(index, true); // Check

checkedListBox1.SetItemChecked(index, false); // Uncheck

Best Regards,




 
 
Andrej Tozon





PostPosted: Visual C# General, CheckListBox select single item... Top

You cannot disable individual items like you can a control, but you can prevent item's checked value to be changed by using ItemCheck event:

private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e)
{
if (e.Index == 2)
{
e.NewValue = e.CurrentValue;
}
}

The above code doesn't allow third item's checked value to be changed. I'm sure you'll find a better way to check whether the item's check state is allowed to change or not (probably through some of item's properties...).

Andrej