hi,
i want the contents of a listbox to appear in separate textboxes... like name, address, number appear in different textboxes when selected...
is that possible? i hope so!
thanks
Printable View
hi,
i want the contents of a listbox to appear in separate textboxes... like name, address, number appear in different textboxes when selected...
is that possible? i hope so!
thanks
Couple of things,
1. How are you populating the contents of the listbox?
2. Is there some sort of separator between the fields in the listbox?
If you are populating it from a database, you can then query the database based on the row selected to poulate the textboxes.
If there is some sort of separator, then you can just do a split on the string.
Quote:
Originally Posted by bmahler
thanks, the contents are called from a db... but could you give me an example of how to query the database based on the row selected?
much appreciated.
Is it a listbox or a listview!
Quote:
Originally Posted by maps
its a listbox
Sure, check out this class, it allows you to set a value for the field, similar to Itemdata in VB6. If you use it you can then store the pk of the row. Then you can just do a query based on the PK.
to add items to tthe listbox you use
VB Code:
Me.ListBox.Items.Add(New DataItem("pk","data"))
then to get the pk back you would use
VB Code:
Dim intPK as Integer = cType(Me.ListBox.SelectedItem,DataItem).ID
Now that you would have the PK you can just wirte a query based on the PK
VB Code:
"SELECT field1,field2 FROM Table WHERE TablePK = " & intPK
Now that you would have the PK you can just wirte a query based on the PKQuote:
Originally Posted by bmahler
thanks altho, i have my items already present in tables and have an ID number for each of them... so how would i go around that? would i use
VB Code:
"SELECT field1,field2 FROM Table WHERE TablePK = " & intPK
does this split the line of the selected item and put each value in separate boxes??