Private Sub DataGridViewMachine_CellContentClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridViewMachine.CellContentClick
frmAddNewWrkReq.txtbxAssetName.Text = DataGridViewMachine.SelectedRows(DataGridViewMachine.CurrentRow.Index).Cells(1).Value.ToString
Me.Hide()
End Sub
如何将数据网格视图中的选定值放到文本框中?
答案 0 :(得分:0)
试试这段代码:
frmAddNewWrkReq.txtbxAssetName.Text = DataGridViewMachine.CurrentRow.Cells("name_of_the_cell").Value.ToString
可能需要在DataGridViewMachine上设置SelectMode=FullRowSelect
答案 1 :(得分:0)
你可以试试这段代码
frmAddNewWrkReq.txtbxAssetName.Text = DataGridViewMachine.Rows(DataGridViewMachine.CurrentRow.Index).Cells(1).Value.ToString