I am trying to set checked state of items in CheckedListbox. It works fine if it is shown by default. If it is placed on a tab page, it is not painting check marks. If the tab page is shown when setting the checked values, it works.
This happens in both .NET tab control and Syncfusion TabControlExt.
Is it a .NET bug? Can some one please help me.
I attached the project.
ADAdministrator Syncfusion Team March 13, 2003 01:26 PM
Yup, I've run into this as well. In Usenet posts, MS has acknowledged this bug. The problem is essentially that any time the visibility changes on a CheckedListBox, it loses its previous selections. Naturally this happens all the time in tab controls when changing tabs.
I think your best bet would be to listen to the events when the checked state of an item changes in the CheckedListBox and maintain a collection of checked items (separately from the CheckedListBox). If the CheckedListBox is hidden, it will lose its selections, but when it is shown again, you can restore the selection from your own collection. Something along those lines should work, I believe that's how we solved it in the past.
ADAdministrator Syncfusion Team March 18, 2003 10:36 AM
I derived my own control from checked listbox and added the following code to fix the bug.
# region Workaround for CheckedListBox bug
// When CheckedList box becomes invisible (e.g. when the tab page
// containing this control is overlapped with another tab page),
// checked state of the items are getting lost. This workaround will
// fix this problem
private bool isItemChecked;
protected override void OnDataSourceChanged(EventArgs e)
int cnt = this.Items.Count;
isItemChecked = new Boolean[cnt];
for(int i = 0; i < cnt; i++)
isItemChecked[i] = GetItemChecked(i);
protected override void OnItemCheck(ItemCheckEventArgs e)
isItemChecked[e.Index] = (e.NewValue == CheckState.Checked);
protected override void OnVisibleChanged(EventArgs e)
if (this.Visible == true)
for(int i =0; i < this.Items.Count; i++)
//Console.WriteLine("Checkstate["+i+"] = " + this.GetItemCheckState(i)
//+", new value="+isItemChecked[i]);
thanks for all your help,