S
Steve Cutting
Hi all,
I have a CheckedListBox on one pane of a TabControl on a form. I find that
whenever the user clicks a different tab then comes back, any checks that
were in the list have disappeared.
After a bit of experimenting I have discovered that the problem only occurs
when the CheckedListBox is using a dataset table as the source. If I
manually add items to it's collection using the properties window, it works
fine. If I bind it to a dataset table though, I get the checkbox clearing
problem.
In order to isolate the problem from the project I'm working on I did the
following:
1. Started a new project
2. Added a tab control with 2 tabs to the form
3. On one pane, added a CheckedListBox
4. Setup db-connection/data-adapter/dataset via the wizards
5. In the Form_load event put the following code:
DataSet11.Clear()
OleDbDataAdapter1.Fill(DataSet11, "Products")
CheckedListBox1.DataSource = DataSet11
CheckedListBox1.ValueMember = "Products.ModelNo"
CheckedListBox1.DisplayMember = "Products.ModelNo"
6. Run
The form loads and the CheckedListBox is populated with the ModelNo fields
from my Products table as expected. Now I check a few lines. I then click
the other tab, and then click back to the original. The checks are gone.
Can anyone shed any light on this behaviour ??
I could just populate my CheckListBox manually, by reading my table with a
datareader and adding the lines one-by-one. I'm still curious as to how/if
the dataset approach can be made to work though.
thanks in advance
Steve
I have a CheckedListBox on one pane of a TabControl on a form. I find that
whenever the user clicks a different tab then comes back, any checks that
were in the list have disappeared.
After a bit of experimenting I have discovered that the problem only occurs
when the CheckedListBox is using a dataset table as the source. If I
manually add items to it's collection using the properties window, it works
fine. If I bind it to a dataset table though, I get the checkbox clearing
problem.
In order to isolate the problem from the project I'm working on I did the
following:
1. Started a new project
2. Added a tab control with 2 tabs to the form
3. On one pane, added a CheckedListBox
4. Setup db-connection/data-adapter/dataset via the wizards
5. In the Form_load event put the following code:
DataSet11.Clear()
OleDbDataAdapter1.Fill(DataSet11, "Products")
CheckedListBox1.DataSource = DataSet11
CheckedListBox1.ValueMember = "Products.ModelNo"
CheckedListBox1.DisplayMember = "Products.ModelNo"
6. Run
The form loads and the CheckedListBox is populated with the ModelNo fields
from my Products table as expected. Now I check a few lines. I then click
the other tab, and then click back to the original. The checks are gone.
Can anyone shed any light on this behaviour ??
I could just populate my CheckListBox manually, by reading my table with a
datareader and adding the lines one-by-one. I'm still curious as to how/if
the dataset approach can be made to work though.
thanks in advance
Steve