Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 单击Cellcontent后将数据行加载到文本框中_C#_Winforms_Datagridview - Fatal编程技术网

C# 单击Cellcontent后将数据行加载到文本框中

C# 单击Cellcontent后将数据行加载到文本框中,c#,winforms,datagridview,C#,Winforms,Datagridview,我有个问题,我已经找了好几个小时了,运气不好 我想要实现的是以下目标。单击datagridview中的一个单元格后,我希望另一个选项卡显示该行(如客户编号支付金额)并将其加载到几个文本框中。是否有人对此功能有一些示例或好的建议?根据您的信息,建议下一种方法: 为datagridview事件创建一个事件处理程序CellDoubleClick(考虑使用DoubleClick-您可以使用您想要的) 然后创建一个添加的函数 void dataGridView1_CellDoubleClick(objec

我有个问题,我已经找了好几个小时了,运气不好


我想要实现的是以下目标。单击
datagridview
中的一个单元格后,我希望另一个选项卡显示该行(如客户编号支付金额)并将其加载到几个
文本框中。是否有人对此功能有一些示例或好的建议?

根据您的信息,建议下一种方法:

为datagridview事件创建一个事件处理程序
CellDoubleClick
(考虑使用DoubleClick-您可以使用您想要的)

然后创建一个添加的函数

void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
    //here we write code for copying rowdata in your textboxes
    DataGridViewRow dgvr = this.dataGridView1.CurrentRow;
    //if datagridview have a predefined columns then using those objects as:
    this.textboxCustomer.text = dgvr.Cells[this.datagridview1_ColCustomer.Name].Value.ToString();
    this.textboxPay.text = dgvr.Cells[this.datagridview1_ColPay.Name].Value.ToString();
}
void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
    //here we write code for copying rowdata in your textboxes
    DataGridViewRow dgvr = this.dataGridView1.CurrentRow;
    //if datagridview have a predefined columns then using those objects as:
    this.textboxCustomer.text = dgvr.Cells[this.datagridview1_ColCustomer.Name].Value.ToString();
    this.textboxPay.text = dgvr.Cells[this.datagridview1_ColPay.Name].Value.ToString();
}