简体   繁体   中英

Load data row in to textboxes after Cellcontent click

I have a problem, I've been searching a few hours now with no luck.

What i want to achieve is the following. After you click on a cell in a datagridview , I want another tab to show and load the row (data like customer number pay amount) in to a few textboxes . Doe anyone have some examples or some good suggestions for this function?

Based on your information suggest a next approach:

Create a event handler for datagridview event CellDoubleClick (think to use a DoubleClick - you can use what you want)

this.datagridview1.CellDoubleClick += dataGridView1_CellDoubleClick;

then create a added function

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM