2013-02-21 51 views
0

我遇到了问题,我一直在搜索几个小时,但没有运气。在Cellcontent点击后将数据行加载到文本框中

我想达到的是以下几点。点击datagridview中的一个单元格后,我需要另一个选项卡来显示并将行(客户号码支付金额等数据)加载到几个textboxes。任何人都有这个功能的一些例子或一些很好的建议?

回答

0

根据您的信息表明下一个方法:

创建datagridview的事件CellDoubleClick事件处理程序(想使用的DoubleClick - 你可以使用你想要的)

this.datagridview1.CellDoubleClick += dataGridView1_CellDoubleClick; 

然后创建一个加功能

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(); 
} 
+0

谢谢,作品像一个魅力。 – 2013-02-25 10:25:28

相关问题