c# - passing cell value from 1 datagrid to another -


i have window form has datagridview , when doubleclick on record whole row copied datagridview.

this code that

        {         string strcon = "data source=*********\\mssql2014;initial catalog=artikelen;persist security info=true;user id=sa;password=*******";         string strsql = "select artikelcode, omschrijving, verkoop_btw_in, verkoop_btw, verkoop_btw_in artikelen";         sqldataadapter sda = new sqldataadapter(strsql, strcon);         sqlcommandbuilder commandbuilder = new sqlcommandbuilder(sda);          // populate new data table , bind bindingsource.         datatable dt = new datatable();         sda.fill(dt);         dbbindsource.datasource = dt;         // bind data grid         dgvparent.datasource = dbbindsource;         string sempdetailstoupdate = dgvparent[1, dgvparent.currentrow.index].value.tostring();         //label1.text = sempdetailstoupdate + " aangekocht";         foreach (datagridviewcolumn dgv_parents_column in dgvparent.columns)         {             dgvchild.columns.add((datagridviewcolumn)dgv_parents_column.clone());         }         datagridviewrow row = new datagridviewrow();         (int icnt = 0; icnt <= dgvparent.rows.count - 1; icnt++)         {             if (dgvparent.rows[icnt].cells[1].value.tostring() == (sempdetailstoupdate))             {                 row = (datagridviewrow)dgvparent.rows[icnt].clone();                 int icolindex = 0;                 foreach (datagridviewcell cell in dgvparent.rows[icnt].cells)                 {                     row.cells[icolindex].value = cell.value;                     icolindex += 1;                 }                 dgvchild.rows.add(row);                 break;      // no matches found. bail out.             }         }         dgvchild.focus();  // set focus on child.     } 

this declared in mousedoubleclick event.

problem1 every time double click on row, it's first record beeing copied. in database there 451 records.

my plan if doubleclick on ex record 201 recorde 201 copied, no thats not case.

problem 2 , 3 ask later, think problem 10 , 2 solved automaticly when problem 1 solved.

can me pls, i'm desperade

a red line under these?

dgvchild.columns.add((datagridviewcolumn)parentcolumn.clone()); 

what this?

dgvchild.columns.add(((datagridviewcolumn)parentcolumn).clone()); 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -