473,406 Members | 2,369 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

CheckedListBox and TabControl problem

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
3 4674
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Chibi | last post by:
Hello! I'm back again with another problem. First of all, thank you to Jacob for helping me understand a bit more about NNTP commands. So now the problem: I have a collection of...
0
by: Microsoft News | last post by:
I'm getting the following error when I shut down my C# .NET v1.1 application: 0xC0000005: Access violation reading location 0x73bc0000 This error didn't occur until I added a...
2
by: CC | last post by:
Hi, We are populating a CheckedListBox from a database. Based on a selection by the user, the CheckedListBox either contains ALL possible members of a set, or a subset of possible members. The...
8
by: Derek Martin | last post by:
Here is some code that I need help with please: Dim result As New ArrayList Try For i = 0 To objecttest1.PersonList.person_returnnumber - 1 result =...
2
by: Manuel Canas | last post by:
Hi there, I'm having this dilema with a checkedlistbox. I have an array of items in there, what I want to accomplish is the following; The user could check all the items in the...
5
by: Brian Mitchell | last post by:
I have no idea what I am doing wrong, but I have a CheckedListBox (Bound to an IList) on a TabControl and everytime I switch tabs I lose my checks. Is there something I'm missing? If I look at the...
0
by: Terry Olsen | last post by:
Dim dirs() as string = Directory.GetDirectories(MyPath) CheckedListBox.DataSource = dirs CheckedListBox.Update For I as Integer = 0 To CheckedListBox.Items.Count - 1...
5
by: mabond | last post by:
Hi Can't believe I've not been able to find the answer to this in the on-line help. I have a CheckedListBox which, via a timer control, is populated with the names of files in a network...
6
by: Steve Teeples | last post by:
Can someone show me an example of how to place a "CheckedListBox" property within a PropertyGrid? -- ----------- Thanks, Steve
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.