How to update a Text cell using a ComboBox cell VB.NET DatagridView

南笙酒味 提交于 2020-12-15 03:48:36

问题


I am using Friend WithEvents PersonName As DataGridViewComboBoxColumn as a column in DataGridView and PersonName DataSoucre is bounded to a database. I would like for when the ComboBox Selection is changed it uses that value to query my database Business Object to find the right value then I want to set the value from the query to the column to the right of the one with the ComboBox which is named Colum3.

But am not use how to access each individual event handler for the ComboBox cell, I tried dgvTable.CellBeginEdit but it triggers too early.

Private Sub dgvTable_CellBeginEdit(sender As Object, e As DataGridViewCellCancelEventArgs) Handles dgvTable.CellBeginEdit
    If e.RowIndex <> -1 And e.ColumnIndex <> -1 Then
        dgvTable.Rows(e.RowIndex).Cells("Colum3").Value = dgvTable.Rows(e.RowIndex).Cells(e.ColumnIndex).Value & "Somevalue from my databse"
    End If
End Sub

来源:https://stackoverflow.com/questions/64931697/how-to-update-a-text-cell-using-a-combobox-cell-vb-net-datagridview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!