Home > Net > Solution: double-click datagridview1 c # a line selected data on datagridview2 add it to the same wi
Solution: double-click datagridview1 c # a line selected data on datagridview2 add it to the same wi
Time:10-02
Solution: double-click datagridview1 c # a line selected data on datagridview2 add it to the same window
CodePudding user response:
Directly write in CellDoubleClick events The selected Row Clone () and then turn strong after Datagridview2. Rows. It is ok to Add This requires two DataGridview column definition is the same
CodePudding user response:
Upstairs said is a kind of method, you can also to data sources
CodePudding user response:
For winform and WPF, as long as the data sources are binding on the Add a DataRow, so the UI controls will automatically response, automatic line, more don't need programming operation UI controls,
CodePudding user response:
Private void datagridview1_CellClick (object sender, DataGridViewCellEventArgs e) { If (" e.R owIndex & gt; 1) { //equivalent to DataGridView DataGridView view=sender as DataGridView; If (the RowCount==0) { return; }
//get selected single content DataRow row=view. Rows [view. CurrentCell. RowIndex];
Datagridview2. Rows. The Add (row [0],... , a row [n]); } }