473,732 Members | 1,991 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CheckedListBox State

CC
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 user can click a button to toggle back-and-forth between showing all or some. The question we have is maintaining state of the CheckedListBox. In other words, if a user has selected "Show MY records" and checks a few boxes, then selects "Show ALL records", we want the items the user has already checked to still be checked when the CheckedListBox is redisplayed.

We have tried many approaches to this with no success. Any help will be GREATLY appreciated. Thank you.
Nov 20 '05 #1
2 2415
Hi ,

Thanks for posting in the community.

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that after you populate a databinding
checkedlistbox from a database, when you redisplay the checkedlistbox, the
checked state was not persists.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

What do you mean by "redisplay" , do you mean set its visible property to
false and then true again?

If so you may take a look at the KB link below.
This is an known issue, as a workaround you may need to do the persist
stuff yourself.
833033 BUG: A checked list box that you bind to a data table in a TabControl
http://support.microsoft.com/?id=833033

Or you can you simple your code and post here for me to reproduce?
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #2
Hi,

Did my last answer help you?
In addition, do you mean when you populate the checkedlistbox and then
check some items and then you repopulate the checkedlistbox, you wants to
persists the checked state.

I think you may still need to persist the checked state yoursefl.
Here is a sample, you may have a look.

Dim checkedList As Collection
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
'Clear the Last Saved Checkedstate List
checkedList = New Collection

'Save the Current Checkedstate List
For Each o As Object In Me.CheckedListB ox1.CheckedItem s
checkedList.Add (o.ToString()) 'the string must be unique, or
you need to select another value to unique identity the item
Next
'RePopulate the checkListBox
Me.CheckedListB ox1.Items.Clear ()
For i As Integer = 1 To 3

Me.CheckedListB ox1.Items.Add(D ataSet11.Table1 .Rows(i).Item(0 ).ToString())
Next

'Restore the Last Saved Checkedstate List
For Each o As String In checkedList
Dim i As Integer =
Me.CheckedListB ox1.FindStringE xact(o.ToString ())
If Not i = -1 Then
CheckedListBox1 .SetItemChecked (i, True)
End If
Next
End Sub

Private Sub Form1_Load(ByVa l sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Me.SqlDataAdapt er1.Fill(Me.Dat aSet11)
For Each o As DataRow In DataSet11.Table 1.Rows
Me.CheckedListB ox1.Items.Add(o .Item(0).ToStri ng())
Next
End Sub
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4097
by: Phil Galey | last post by:
In VB.NET, is there a way to make it so the user can select items in a CheckedListBox, but is NOT able to check them? Even if I set Locked = True, the user is still able to both select and check items. The Locked property appears to be a dummy switch. Setting the CheckOnClick property to False gets me half way home, as it requires the user to click a second time in order to toggle the checkbox of the selected item; however, I need to...
0
2042
by: pothik05 | last post by:
I can not make the DrawItem event to work on the CheckedListBox control. I suggestion will be highly appreciated. I have the following code. The code works for ListBox and the second item (Two) is displayed in red in the ListBox but the CheckedLIstBox displays everything in black (where it should be displayed as red). Public Sub New() MyBase.New()
4
3795
by: Matthew | last post by:
Hi, I am using a checkedlistbox on a windows form and binding it to a collection of classes. clbAliases is the checkedlistbox control selectedplace is a class with property placealiases.This property is a collection of placealias classes. Hopefully the rest is self-explanatory..
3
1220
by: Trapulo | last post by:
I've some problem checking items in a checkedlistbox by code: For jj As Int32 = 0 To cbTimeOptions.Items.Count - 1 ' cut: logic to set maycheck variable cbTimeOptions.SetItemChecked(jj, maycheck ) Next
8
1803
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 = objecttest1.PersonList.time_returnpunches(objecttest1.PersonList.person_getb yid(i).userid, "03/08/2004", "03/09/2004", True, False) 'The above line returns an object with several proerties, namely, a punch id that I want to be able to get out of the checkedlistbox collection:
2
2304
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 checkedlistbox, but always have at list one item always checked. so if the user has the last item checked and he/she wants to uncheck it, the item should reset it self to a checked state
4
2187
by: Moondog | last post by:
Simple question: How can I test if an item has been checked in a CheckedListBox? My scenario is if a user clicks on my CheckedListBox, and the item has not been checked yet, do some event, if it has already been checked, do something else. Thanks, Dominic Isaia
3
6201
by: Jerry Spence1 | last post by:
I am trying to capture when an item in the CheckedListBox occurs. I am using the event: CheckedListBox1_ItemCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemCheckEventArgs) Handles CheckedListBox.ItemCheck However, this fires before the item is actually checked. So to get over this problem I tried: If e.CurrentValue = CheckState.Unchecked Then
5
6864
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 folder. The "check mark" for each item in the control is determined by the boolean value of a custom property field of the file. That value is found using microsoft's dsofile.dll class.
0
8773
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9445
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9234
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9180
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8186
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6733
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6030
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
2721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2177
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.