I have two gridviews, and when the user highlights a line on the first gridview and clicks on a button, Then let him the second gridview.
When I click on the button that adds the record, but it only adds the last line I selected (if I select 20 rows, only the last is added).
private zeros button 1_Click_1 (object sender, eventAgds E) {DataGridViewRow dr = dataGridView1 Selected road [0]; DtItems.Columns.Add ("city_ID"); DtItems.Columns.Add ("CITY_NAME"); DtItems.Columns.Add ("status"); DtItems.Columns.Add ("Date"); If (DataGridView1.Rows.Count> 1) {for (int i = 0; i & lt; dataGridView1.Rows.Count - 1; i ++) {if (dataGridView1.Rows [i] .cel [0 ] .Value! = Void) {DataRow row; Line = dtItems.NewRow (); Line ["city_ID"] = datagrid view 1. Rao [i]. [1] Call. Value Toasting (); Line ["city_name"] = datagrid view 1. Ro [i]. [2]. Room Tie (string); Line ["status"] = datagrid view 1. Rao [i]. [3] .Valuue. Toasting (); Line ["date"] = datagrid view 1. Rao [i]. [4] .Valuue. Toasting (); DtItems.Rows.Add (line); }}} Form 2 FM = New Form 2 (DTITs); Frm.ShowDialog (); } Copy this code into Form 2:
public form 2 (datatale dtIt) {dtItems = dtIt; InitializeComponent (); } Private Zero AddEmptyRows () {for (int i = 1; i & lt; = 5; i ++) {dataGV.Rows.Add (); }} Private Zero Form 2_load (Object Sender, EventEurge E) {AddEmptyRows (); For (Int i = 0; I
Comments
Post a Comment