DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: List Box and Database Question

  1. #1
    Join Date
    Aug 2006

    List Box and Database Question

    I have a question that I was hoping someone could help me out with.

    I am using VB.NET 2005 express with SQL server express and I have a list box that is bound to a table in a dataset. I want to be able to select one of the items in the list box and then use an item that corresponds to this item in the list box and I do not know how to do this.

    For example, if I had a table named Person and this table had two fields one named PersonID (which is the key field), PersonName, and PersonAge. Say I had PersonName bound to the list box. So say I click on one of the PersonNames in the list box and then wanted to use the PersonAge, that corresponded to the name I had clicked, in a calculation. How would I access the PersonAge value.


  2. #2
    Join Date
    Jul 2004
    I think what you need is something like this:

    listbox.DataSource = dsDataset.Tables("TableName")
    listbox.DisplayMember = "PersonName"
    listbox.ValueMember = "PersonAge"

    I do the same thing with a combobox. It works for me. Hope it works for you.


Similar Threads

  1. Replies: 1
    Last Post: 12-17-2005, 07:05 PM
  2. Replies: 0
    Last Post: 08-25-2002, 08:50 PM
  3. Replies: 0
    Last Post: 08-23-2002, 04:25 AM
  4. Replies: 2
    Last Post: 08-23-2002, 04:22 AM
  5. Check box isssue when bound to a database column
    By Narayan in forum VB Classic
    Replies: 0
    Last Post: 04-10-2001, 10:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center