CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: listview

  1. #1
    Join Date
    Feb 2000
    Posts
    440

    listview

    Hi,

    I have a listview and I add items like this

    myLV.AddItem ,"k1", "Hello"
    myLV.AddItem ,"k2", "Hi"
    myLV.AddItem ,"k2", "etc."
    ...

    then I want to find an item using the key.

    I realize I can iterate all items one by one,
    but is there faster way to find an item by key?

    thanks.

    Valery Iskarov Nikolov
    Software Dynamics

  2. #2
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868

    Re: listview

    What listview control are you using? The one I have (Microsoft's) doesn't have an AddItem method???


  3. #3
    Join Date
    Feb 2000
    Posts
    440

    Re: listview

    ok, my mistake, in my post instead of

    myLV.AddItem ,"k1", "Hello"
    myLV.AddItem ,"k2", "Hi"
    myLV.AddItem ,"k2", "etc."

    I should have written


    myLV.ListItems.Add ,"k1", "Hello"
    myLV.ListItems.Add ,"k2", "Hi"
    myLV.ListItems.Add ,"k2", "etc."



    Valery Iskarov Nikolov
    Software Dynamics

  4. #4
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868

    Re: listview

    I think it can be used interchangeably anytime you would normally use the "index" parameter as in:


    private Sub Command1_Click()
    MsgBox ListView1.ListItems("K2").Text
    End Sub

    private Sub Form_Load()
    ListView1.ListItems.Add , "K1", "One"
    ListView1.ListItems.Add , "K2", "Two"
    ListView1.ListItems.Add , "K3", "Three"
    End Sub





  5. #5
    Join Date
    Feb 2000
    Posts
    440

    Re: listview


    You are quite right,

    Thanks,

    Valery Iskarov Nikolov
    Software Dynamics

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