CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2001
    Posts
    49

    Listview Selected Bug?

    I have done a search and didn't find what I was looking for.

    I have attached a small program to demo the bug. Just run the program and click on each button. You will know what I am talking about after looking at the code.

    Technically, to solve the issue I could use the version 5 but I need some features that are in version 6 so any help?

    I didn't find anything in MSDN or MS KB for known bug or workarounds.

    Is MS aware of this bug?

    Remember to run and click on the button without highlighting anything.
    Attached Files Attached Files

  2. #2
    Join Date
    Sep 2002
    Location
    England
    Posts
    530
    try this:
    Code:
    Option Explicit
    
    Private Sub cmdRemove_Click()
    Dim i As Integer
    For i = 1 To ListView1.ListItems.Count
        If ListView1.ListItems(i).Selected Then
            MsgBox ListView1.ListItems(i).Text
        End If
    Next i
    End Sub
    
    Private Sub Command1_Click()
    Dim i As Integer
    For i = 1 To ListView2.ListItems.Count
        If ListView2.ListItems(i).Selected Then
            MsgBox ListView2.ListItems(i).Text
        End If
    Next i
    
    End Sub
    
    Private Sub Form_Load()
    Dim i As Integer
    For i = 1 To 5
        ListView1.ListItems.Add , , "List" & i
        ListView2.ListItems.Add , , "List" & i
    Next i
    ListView1.ListItems.Item(ListView1.SelectedItem.Index).Selected = False
    End Sub
    hope it helps

  3. #3
    Join Date
    Oct 2003
    Location
    .NET2.0 / VS2005 Developer
    Posts
    7,104
    i take it this was the only line that actually changed:

    ListView1.ListItems.Item(ListView1.SelectedItem.Index).Selected = False

    ?
    "it's a fax from your dog, Mr Dansworth. It looks like your cat" - Gary Larson...DW1: Data Walkthroughs 1.1...DW2: Data Walkthroughs 2.0...DDS: The DataSet Designer Surface...ANO: ADO.NET2 Orientation...DAN: Deeper ADO.NET...DNU...PQ

  4. #4
    Join Date
    Sep 2002
    Location
    England
    Posts
    530
    yeah

  5. #5
    Join Date
    Sep 2001
    Posts
    49
    Yes, it helps.

    But WHY?

    Who in the world was the first item selected = true when it shouldn't? It is not highlighted. Who did MS listen to?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured