P
Patrick Dugan
I am using Visual Studio 2005 (visual basic) and Compact Framework 2.0
I have a ListView that will contain several Items. The ListView has
checkboxes enabled.
Whenever the user clicks on a checkbox to change it (check or uncheck) I
want to indicate
how many items are currently checked. This routine below looks correct to
me, but each time
I check or uncheck the number reported back is always the previous count and
not the current count of items that are checked.
Private Sub ListView1_ItemCheck(ByVal sender As Object, ByVal e As
System.Windows.Forms.ItemCheckEventArgs) Handles ListView1.ItemCheck
Dim CheckCount As Integer
Dim NItem As ListViewItem
CheckCount = 0
For Each NItem In ListView1.Items
If NItem.Checked Then
CheckCount = CheckCount + 1
end if
Next
Msgbox("Number of items checked are: " & CheckCount)
End Sub
Can anybody tell me why the CheckCount is always behind? For example if no
items are checked and then I check
one item, the checkcount is still zero. When I uncheck that same item then
the checkcount is now 1.
It is like the state of being checked or unchecked for any item happens
after the ItemCheck event in the ListView.
I looked for an ItemChecked event but no such event shows.
Help!
Patrick Dugan
I have a ListView that will contain several Items. The ListView has
checkboxes enabled.
Whenever the user clicks on a checkbox to change it (check or uncheck) I
want to indicate
how many items are currently checked. This routine below looks correct to
me, but each time
I check or uncheck the number reported back is always the previous count and
not the current count of items that are checked.
Private Sub ListView1_ItemCheck(ByVal sender As Object, ByVal e As
System.Windows.Forms.ItemCheckEventArgs) Handles ListView1.ItemCheck
Dim CheckCount As Integer
Dim NItem As ListViewItem
CheckCount = 0
For Each NItem In ListView1.Items
If NItem.Checked Then
CheckCount = CheckCount + 1
end if
Next
Msgbox("Number of items checked are: " & CheckCount)
End Sub
Can anybody tell me why the CheckCount is always behind? For example if no
items are checked and then I check
one item, the checkcount is still zero. When I uncheck that same item then
the checkcount is now 1.
It is like the state of being checked or unchecked for any item happens
after the ItemCheck event in the ListView.
I looked for an ItemChecked event but no such event shows.
Help!
Patrick Dugan