سؤال

Checkbox named 'select all' for checkedlistbox. when unCheck any item in checkedlistbox it unCheck 'select all' checkebox, below code does this job.

but when all items are checked in checkedlistbox it should check 'select all'.

for (int i = 0; i < checkedListBox1.Items.Count; i++) {
    if (!checkedListBox1.GetItemChecked(i))
        checkBox1.Checked = false;
}
هل كانت مفيدة؟

المحلول

try something like this

if (checkedListBox1.CheckedItems.Count == checkedListBox1.Items.Count)
{
    //your code goes here  
}

نصائح أخرى

Try this:

if (checkedListBox1.CheckedItems.Count == checkedListBox1.Items.Count)
{
    //your code goes here  
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top