Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql VB.net 2013根据列表框选择显示数据库记录_Mysql_Wpf_Vb.net_Listbox - Fatal编程技术网

Mysql VB.net 2013根据列表框选择显示数据库记录

Mysql VB.net 2013根据列表框选择显示数据库记录,mysql,wpf,vb.net,listbox,Mysql,Wpf,Vb.net,Listbox,我想根据我的列表框选择将数据库记录显示到文本框中 我已经将数据库记录按名称显示到列表框中,如下所示 Private Sub getPurchases() cmd = New MySqlCommand("SELECT * FROM detail_buy ORDER BY id DESC", conn) da = New MySqlDataAdapter da.SelectCommand = cmd dt.Clear() da.Fill(dt) LBP

我想根据我的列表框选择将数据库记录显示到文本框中

我已经将数据库记录按名称显示到列表框中,如下所示

Private Sub getPurchases()
    cmd = New MySqlCommand("SELECT * FROM detail_buy ORDER BY id DESC", conn)
    da = New MySqlDataAdapter
    da.SelectCommand = cmd
    dt.Clear()
    da.Fill(dt)
    LBPmb.DataSource = dt
    LBPmb.ValueMember = "name"
End Sub

现在我想在单击列表框上的“名称”时,在每个文本框中显示其他值,如ID、价格、总额等。这可能吗?

您也应该将相同的
数据表
绑定到
文本框
,例如

With myListBox
    .DisplayMember = "ColumnToDisplay1"
    .ValueMember = "PKColumn"
    .DataSource = myDataTable
End With

myTextBox.DataBindings.Add("Text", myDataTable, "ColumnToDisplay2")
当您在
列表框
中进行选择时,
文本框
将自动填充