Results 1 to 4 of 4

Thread: listbox row selected

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2011
    Posts
    3

    Question listbox row selected

    I've being trying to work out a problem i've being having for a while now and i'm not sure if i'm over complicating it.

    When a form loads, it uses a for next loop to load an array of peoples names into a list box. However i want to extract the persons ID once their name has being clicked. I can make this work by using another for next loop until the selected name matches the an array number. However it fails if there are two people of the same name.

    Is there a command or piece of code that can extract the row number of the item selected?

    This problem has being bugging me for weeks now and any help would be much appreciated.

  2. #2
    Frenzied Member MattP's Avatar
    Join Date
    Dec 2008
    Location
    WY
    Posts
    1,227

    Re: listbox row selected


  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2011
    Posts
    3

    Re: listbox row selected

    Aah i think i misused this when i tried it the first time. Thanks ever so much, finally fixed that little use.

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,104

    Re: listbox row selected

    Another option would be to use databinding. If you were to have a datatable with the name and id, you could bind the listbox to the table and set the DisplayItem to the name and the ValueItem to the ID. Then you could get either part from the listbox. However, it sounds like you have two distinct arrays for the two pieces, in which case you can't bind to both.
    My usual boring signature: Nothing

Tags for this Thread

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