Re: [2005]split the selected contents in a listbox?
Originally Posted by bmahler
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.
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.
Last edited by Graycode; Sep 21st, 2006 at 09:34 AM.
Re: [2005]split the selected contents in 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
Boooya
Visual Studio 2008 Professional
Don't forget to use [CODE]your code here[/CODE] when posting code
Don't forget to rate helpful posts!
If you're question was answered please mark your thread [Resolved]
Re: [2005]split the selected contents in a listbox?
Originally Posted by bmahler
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
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??