Results 1 to 11 of 11

Thread: No more ListView.FindItem()?

  1. #1

    Thread Starter
    Addicted Member AlvaroF1's Avatar
    Join Date
    Sep 2002
    Location
    SP - Brazil
    Posts
    200

    Question No more ListView.FindItem()?

    Where's the ListView.FindItem function?
    VB6 code:

    VB Code:
    1. Private Sub Command1_Click()
    2.     Dim FoundItem As ListItem
    3.     Set FoundItem = ListView1.Find("Something", 0)
    4.     If FoundItem Is Nothing Then
    5.         MsgBox "Not found"
    6.     Else
    7.         MsgBox "Found"
    8.     End If
    9. End Sub
    What about VB .NET?


    Thanks.
    Last edited by AlvaroF1; Aug 19th, 2003 at 03:38 PM.

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    VB Code:
    1. ListView1.Items.IndexOf(listviewitem)

  3. #3

    Thread Starter
    Addicted Member AlvaroF1's Avatar
    Join Date
    Sep 2002
    Location
    SP - Brazil
    Posts
    200
    But listviewitem cannot be a string, can it?

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Do you mean this way : This search for item (which is string) into the collection of listview . Output is the index 0 (if it's alone there)

    VB Code:
    1. Dim listviewitem As New listviewitem("aaaaa")
    2. messagebox.Show (ListView1.Items.IndexOf(listviewitem))

  5. #5
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by Pirate
    Do you mean this way : This search for item (which is string) into the collection of listview . Output is the index 0 (if it's alone there)

    VB Code:
    1. Dim listviewitem As New listviewitem("aaaaa")
    2. messagebox.Show (ListView1.Items.IndexOf(listviewitem))
    hmm but does that work? have you tried it? I dont have VS here to try it... someone let me know if it works, because if it does, I would feel really dumb

    I wrote this stupid little funciton a while ago, dunno how ti works, dunno if it has any limitations, don't feel like reading my own code
    VB Code:
    1. Public Shared Function ListViewFind(ByVal txt As String, ByVal lvw As ListView) As Integer
    2.  
    3.             Dim li As ListViewItem
    4.             For Each li In lvw.Items
    5.                 If li.Text = txt Then
    6.                     Return li.Index
    7.                 End If
    8.             Next
    9.  
    10.             Return -1
    11.         End Function
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  6. #6

    Thread Starter
    Addicted Member AlvaroF1's Avatar
    Join Date
    Sep 2002
    Location
    SP - Brazil
    Posts
    200
    Thank you all.

    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Dim FoundItem As New ListViewItem("Something")
    3.         If ListView1.Items.IndexOf(FoundItem) = -1 Then
    4.             MsgBox("Not found")
    5.         Else
    6.             MsgBox("Found")
    7.         End If
    8.     End Sub

  7. #7
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    So , it's working Mr.Polite . I thought I was going insane again .

  8. #8
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by Pirate
    So , it's working Mr.Polite . I thought I was going insane again .


    pretend this didn't happen plz
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  9. #9

    Thread Starter
    Addicted Member AlvaroF1's Avatar
    Join Date
    Sep 2002
    Location
    SP - Brazil
    Posts
    200
    MrPolite was right.

    I'm testing this code and it's not working!

    Sorry!

  10. #10
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Too late .

  11. #11
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    interesting!
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

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