كما هو واضح من السؤال
انا قمت بربط ListBox بقاعدة البيانات بحيث يضهر حقل الاسم في ListBox اريد عند الضفط على الاسم يضهر البيانات المرتبطه بالاسم في textbox المخصص لكل خانه
[ATTACH=CONFIG]1882[/ATTACH]
Public Sub fillListBox(ByVal cbo As ListBox, ByVal tabl1 As String, ByVal col_name As String, ByVal col_value As String, ByVal whr As String)
Try
Dim comb As String
comb = ""
comb = "Select " + col_name + " , " + col_value + " From " + tabl1 + " " + whr
Dim sda As New SqlDataAdapter(comb, sqlcon)
Dim ds As New DataSet()
sda.Fill(ds)
cbo.DataSource = ds.Tables(0)
cbo.DisplayMember = col_name
cbo.ValueMember = col_value
Public Sub fillListBox(ByVal cbo As ListBox, ByVal tabl1 As String, ByVal col_name As String, ByVal col_value As String, ByVal whr As String)
Try
Dim comb As String
comb = ""
comb = "Select " + col_name + " , " + col_value + " From " + tabl1 + " " + whr
Dim sda As New SqlDataAdapter(comb, sqlcon)
Dim ds As New DataSet()
sda.Fill(ds)
cbo.DataSource = ds.Tables(0)
cbo.DisplayMember = col_name
cbo.ValueMember = col_value
Catch ex As Exception
End Try
End Sub
End Class
المعذرة على التأخير................
بناءً على طريقتك في تعبئة الـListView1 (وهي الطريقة الصحيحة) يتم جلب البيانات بناءً على العنصر المحدد في الـ ListView1 كالتالي
طبعاً لا علم لي بتركيبة قاعدة البيانات لديك، لهذا تأكد من اسم table1 الجدول واسم الحقل col_value
تفضل
كود :
Private Sub ListBox1_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedValueChanged
Dim sql As String = " SELECT * FROM [color=#ff0000]table[/color] WHERE [color=#ff0000]col_value[/color]=@col_value "
Dim command As New SqlCommand(sql, conn)
command.Parameters.AddWithValue("@col_value", Me.ListBox1.SelectedValue)
Dim dataAdapter As New SqlDataAdapter(command)
Dim dataTable As New DataTable
If dataAdapter.Fill(dataTable) > 0 Then
[color=#ff0000]'' dataTable.Rows(0) هنا قم بتعئبة الأدوات من[/color]