You can do something like this:
dtItems - the items datatable, has ItemName and ItemID
ListBox1 - the listbox for displaying the items
'assign the dtItems table to the listbox
ListBox1.DisplayMember = "ItemName"
ListBox1.ValueMember = "ItemID"
Next, set up the SelectedIndexChanged event for the listbox:
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Dim ThisItemID As String = ""
ThisItemID = ListBox1.SelectedValue
'now that you have the ItemID for the selected item, there are a number of ways to display the details
'assume a separate form called frmDetails, with a Public property called ItemID:
Dim fDetails As frmDetails
fDetails.ItemID = ThisItemID
fDetails.ShowDialog()
End Sub
Now, in frmDetails you would do this:
'first, create the Public property for ItemID
Dim sItemID As String = ""
Public Property ItemID() As String
Get
Return sItemID
End Get
Set(ByVal value As String)
sItemID = value
End Set
End Property
Now, in the form's Load event, get the details data:
Private Sub frmDetails_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim SQLStr As String = "Select * from tblDetails where ItemID='" & sItemID & "'" 'use the appropriate table name
'execute the SQL and display the result
End Sub
Hope this helps.
I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
Arrrr, mateys! Ye needs ta be preparin' yerselves fer
Talk Like a Pirate Day!