By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,239 Members | 1,493 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,239 IT Pros & Developers. It's quick & easy.

CheckedListBox and TabControl problem

P: n/a
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

Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
You're not alone.

Here is my posting about this problem from 2 years ago. Don't think I've
ever found a good solution.

http://tinyurl.com/557uy

I wonder if they fixed this in 2005?

Greg

"Steve Cutting" <sc******@optusnet.com.au> wrote in message
news:9d********************************@4ax.com...
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

Nov 20 '05 #2

P: n/a
On Sat, 24 Jul 2004 09:27:12 -0400, "Greg Burns"
<greg_burns@DONT_SPAM_ME_hotmail.com> wrote:
You're not alone.

Here is my posting about this problem from 2 years ago. Don't think I've
ever found a good solution.

http://tinyurl.com/557uy

I wonder if they fixed this in 2005?


Thanks Greg. I had wondered if it was just a bug, but assumed I was just
doing something wrong :P I am only just learning vb.net, and this sort of
thing doesn't exactly help matters.

I have already implemented a work-around for another CheckedListBox in my
form. For that one I'm able to restore the checks using data in my table, so
I just have a routine that runs on the indexchanged event of the tabcontrol.

For this CheckedListBox (ie the one I posted about) I think I will just
redesign my code and add the list items manually via a datareader, since I
have no way of restoring the checks without creating a temp array/collection
to store them.

thanks again
Steve

Nov 20 '05 #3

P: n/a
WOW! I ran into this a long time ago and fought with it for a long time.
I ended up blaming Infragistics, as I was using some of their stuff as well.
After MUCH hair pulling, I "think" I narrowed it down to the Tab control as the
source of the problem.
I had other controls that had problems as well, that seemed to work just fine in
all other contexts.
I also experienced an issue where the presence of the tab control causes my Form
to resize at run time.
If I had things below the tab control, sometimes it would arbitrarily resize the
form to fit the bottom of the tab.
I have NO docking, NO resize code, NOTHING to affect the size of the form.

FWIW, I accidentally stumbled on something that works for me.
I really needed a multi-color checked list box with a custom right-click context
menu, so I created an inherited user control and overrode the OnDrawItem event.
When using my version of the control, I have not experienced this problem
anymore.

Gerald

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:u4**************@tk2msftngp13.phx.gbl...
You're not alone.

Here is my posting about this problem from 2 years ago. Don't think I've
ever found a good solution.

http://tinyurl.com/557uy

I wonder if they fixed this in 2005?

Greg

"Steve Cutting" <sc******@optusnet.com.au> wrote in message
news:9d********************************@4ax.com...
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


Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.