Results 1 to 3 of 3

Thread: [RESOLVED] [2005] search an object in a listbox

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    128

    Resolved [RESOLVED] [2005] search an object in a listbox

    i have a class "item" and this is how my class looks and how i populate" item"objects my listbox list1

    VB Code:
    1. public class item
    2.  
    3.  Public fname As String, pid As Long
    4.  
    5.         Public Sub New(ByVal id As Long, ByVal nm As String)
    6.             fname = nm
    7.             pid = id
    8.         End Sub
    9.  
    10.         Public Overrides Function ToString() As String
    11.             Return pid & vbTab & fname
    12.         End Function
    13. end class
    14.  
    15.  Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles form1.Load
    16.      list1.items.add(new item(1,"myname"))
    17.     End Sub

    my question is how can i search for a particular object in the list provided my search criteria is the id ???

  2. #2
    Hyperactive Member
    Join Date
    Aug 2003
    Location
    Wigan, UK
    Posts
    291

    Re: [2005] search an object in a listbox

    Try using FindString but with the number(as string) followed with vbab
    VB Code:
    1. 'something like this
    2. If List1.FindString("your number" & vbTab) <> -1 Then
    3. 'id found

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    128

    Re: [2005] search an object in a listbox

    wa nice!!!! thx!!!!!!!!!!!

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