VB组合框索引更改datagridview鼠标单击行选择

时间:2015-11-05 16:54:30

标签: vb.net datagridview combobox

我想在双击datagridview中的行时将我的文本框字段设置为行列值。我已经想出如何填充我的文本框字段,但是,我在组合框中的一个字段,我似乎无法根据所选行的列值选择下拉值。这就是我目前所拥有的。

Private Sub dgvCustomers_MouseDoubleClick(sender As Object, e As MouseEventArgs) Handles dgvCustomers.MouseDoubleClick

    Dim row As DataGridViewRow = dgvCustomers.SelectedRows(0)

    tbMasterContactID.Text = dgvCustomers.SelectedRows(0).Cells(0).Value.ToString
    tbCompany.Text = dgvCustomers.SelectedRows(0).Cells(1).Value.ToString
    tbContact.Text = dgvCustomers.SelectedRows(0).Cells(2).Value.ToString
    tbAddress1.Text = dgvCustomers.SelectedRows(0).Cells(3).Value.ToString
    tbAddress2.Text = dgvCustomers.SelectedRows(0).Cells(4).Value.ToString
    tbCity.Text = dgvCustomers.SelectedRows(0).Cells(5).Value.ToString
    tbState.Text = dgvCustomers.SelectedRows(0).Cells(6).Value.ToString
    tbCountry.Text = dgvCustomers.SelectedRows(0).Cells(7).Value.ToString
    tbZip.Text = dgvCustomers.SelectedRows(0).Cells(8).Value.ToString
    tbZip4.Text = dgvCustomers.SelectedRows(0).Cells(9).Value.ToString
    tbEmail.Text = dgvCustomers.SelectedRows(0).Cells(10).Value.ToString
    tbPhone.Text = dgvCustomers.SelectedRows(0).Cells(11).Value.ToString

    tbStatus.SelectedIndex = tbStatus.FindString(dgvCustomers.SelectedRows(0).Cells(12).Value.ToString)
End Sub

0 个答案:

没有答案