在我的vb 2010项目中,我有一个组合框,可使用诸如..这样的BindingSource将数据加载到其中。
Private Sub CreditorN_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles CreditorN.GotFocus
Dim SqlAdapt As SqlDataAdapter
Dim SqlDs As DataSet
SqlAdapt = New SqlDataAdapter("Select CreditorN, CreditorID from Creditors", myConnection)
SqlDs = New DataSet
SqlAdapt.Fill(SqlDs, "CreditorsList")
BindingSource1.DataSource = SqlDs.Tables(0)
CreditorN.DataSource = BindingSource1
CreditorN.DisplayMember = "CreditorN"
End Sub
现在,我要做的是当我从组合框中选择CreditorN时,我想在BindingSource中获取相应的ID。因为基于选择的内容,所以我执行另一个查询。而且某些客户不能使用所选名称。
在datagridview中,我使用
Dim selectedrowindex as integer
Dim selectedrow as datagridviewrow
Selectedrowindex = CreditorsList.SelectedCell(0).rowindex
Selectedrow = creditorsList.rows(selectedrowindex)
由此,我可以在datagridview中单击连续获得的任何单元格。
但是我不知道如何处理组合框和BindingSource