|
Could anyone let me know if there is something amiss in this code? I want to enable a menu option only if the user has checked on atleast one of the listview items. The items in listview are added at run time Private Sub ListView1_ItemCheck(ByVal sender As Object, _ ByVal e As System.Windows.Forms.ItemCheckEventArgs) Handles ListView1.ItemCheck Dim checkedItems As ListView.CheckedListViewItemCollection = ListView1.CheckedItems() 'MsgBox(checkedItems.Count) If checkedItems.Count > 0 Then SomeMenuItem.Enabled = True Else SomeMenuItem.Enabled = False End If End Sub The code is returning count as zero when I check on an item in listview. However, on consecutive check it atleast returns some values E.g. On the first check, the count returned is '0'. However, on the second check, the count returned is '1' If I go and uncheck any one of the two items, then the count returned is '2' ! Can anyone please explain this behavior of "Count" in CheckedListViewItemCollection? ~Apploader
|