I am working with a checkedlistbox and I am having a small issue. Here is the code that I am using.
Private Sub CListBox1_ItemCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemCheckEventArgs) Handles CListBox1.ItemCheck
Dim itemchecked As Object
For Each itemchecked In CListBox1.CheckedItems
Now the problem that I am having is when I check an item in the listbox it is suppost to bring up a msgbox displaying each item that is checked, however; that isn't what happens. Instead I get a msgbox that displays all the times thats checked except for the one that I just checked.
I check Item#1 - Nothing happens
Then I check Item #2 - Msgbox comes up with the name of Item#1 and then nothing else.
Item# 3 - I get a msgbox for 1 & 2 but not 3 and so on.
What am I doing wrong?
I might also note that if I change:
I get a msgbox displaying the number of items that is checked, however; it is also 1 short of what it should be.
I think this event fires when you click on the item but before it is considered to be checked. This would allow some pre processing/validation before an item is selected.
As noted in the documentation, the ItemCheck event "occurs when the checked state of an item changes." In other words, it's intended to provide information about the checked state of a single item, not the entire list.
Private Sub CListBox1_ItemCheck(ByVal sender As Object, _
ByVal e As System.Windows.Forms.ItemCheckEventArgs) _
' Display msgbox for previous checked items
For Each itemchecked As Object In CListBox1.CheckedItems
' If this event is fired because item was checked,
If e.NewValue <> CheckState.Unchecked Then
' Display msgbox for newly-checked item
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
By manumishra in forum Database
Last Post: 06-09-2008, 05:28 PM
By Beginner in forum .NET
Last Post: 01-27-2002, 06:35 PM
By Saurabh in forum dotnet.announcements
Last Post: 09-19-2001, 07:48 AM
By Michael in forum Mobile
Last Post: 07-11-2001, 06:18 PM
By John Lockwood in forum Web
Last Post: 04-06-2000, 05:58 PM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center