Windows Develop Bookmark and Share   
 index > Windows Forms General > I wish this bug would go away...
 

I wish this bug would go away...

Steps to reproduce:

Add a listview to a form. 
Set its "view" property to "Details". 
Set its "checkboxes" property to "True". 
Add a column to it. 

Put this code in the form load event: 

    Private Sub Form1_Load... 
        Dim i As Integer 
        For i = 0 To 50 
            ListView1.Items.Add("Item " & i.ToString) 
        Next 
    End Sub 


Put a button on the form. 
Under the button, add this code: 

    Private Sub Button1_Click... 
        Dim li As ListViewItem 
        Dim i As Integer 
        Debug.WriteLine("") 
        For Each li In ListView1.CheckedItems 
            Debug.WriteLine(li.Text) 
        Next 
        For i = 0 To ListView1.CheckedIndices.Count - 1 
            Debug.WriteLine(ListView1.Items(ListView1.CheckedIndices.Item(i)).Text) 
        Next 
        For i = 0 To ListView1.CheckedItems.Count - 1 
            Debug.WriteLine(ListView1.CheckedItems(i).Text) 
        Next 
        Debug.WriteLine("") 
    End Sub 

Now, check "Item 3", then click the button.  You will see this in the output window: 

Item 3 
Item 3 
Item 3 

Now for the good part... check "Item 4", uncheck "Item 3", and click the button again. 
Here is what you see in the output window: 

Item 4 
Item 3 
Item 3 

Oops....
MigrationUser 1  Tuesday, February 18, 2003 5:58 PM
Thanks for the bug report.  There is a known issue with ListView's CheckedItems and CheckedIndices properties.  It will be fixed in a future version of the .NET Framework.

Thanks,
Kevin
MigrationUser 1  Wednesday, February 19, 2003 4:42 PM

You can use google to search for other answers

Custom Search

More Threads

• shortcut in view/sidebar
• Activate an application
• Flicker problem in GDI+ drawing
• PRINTFORM control problem with print client area only
• axWebBrowser and NewWindow2
• Async methods
• Break WinForm into 3 equal areas
• Opening a form in a new thread? [VB2005]
• print preview problem its urgent
• Namespace conflict after adding a Windows Form to a project