我在 Windows 窗体中有一个 datagridview 和文本框,当我单击 datagridview 的一个单元格时,值必须复制到文本框。
我收到一个错误:
System.Windows.Forms.DataGridCell Does not contain a definition for RowIndex
我试过这段代码
void dataGridView1_Click(object sender, EventArgs e)
{
Txt_GangApproved.Text=dataGridView1.CurrentCell.RowIndex.Cells["NO_OF_GANGS_RQRD"].Value.ToString();
}
最佳答案
foreach (DataGridViewRow RW in dataGridView1.SelectedRows) {
//Send the first cell value into textbox'
Txt_GangApproved.Text = RW.Cells(0).Value.ToString;
}
关于c# - 文本框中所选 dataGridView 单元格的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13374575/