I have two forms Form1(DGV1) and Form2(DGV2) with Datagridview control on both the forms.
On Form1 there is a button link to Form2 where user can add rows to Form1 datagridview(DGV1) ..In Form2 Datagridview there is a checkbox in the first column and the user can select only one row at a time.There are two button on Form2 1) Done 2) Add Items
When user clicks on Add Items by selecting the rows one after another,the rows must be added to the datagridview on Form1 and when Done button is clicked Form 1 should be displayed with all the rows that are added.
I have achieved this using the below code:
int inde x= objQM.gvItemDetails.Rows.Add();
DataGridViewRow row = (DataGridViewRow)objQM.gvItemDetails.Rows[index];
decimal UnitCos = Convert.ToDecimal(gvInventory.Rows[RowIndex].Cells[8].Value.ToString()); row[0] = false;
row[1] = 1;
row[2] = gvInventory.Rows[RowIndex].Cells[6].Value.ToString();
row[3] = LoadSellQty();
row[4] = Convert.ToDecimal(gvInventory.Rows[RowIndex].Cells[8].Value.ToString());
row[5] = LoadSellQty() * UnitCost;
row[7] = Convert.ToInt32(gvInventory.Rows[RowIndex].Cells[1].Value.ToString());
Now the problem is to validate if the same row is added into DGV1 on Form1 when AddItems button is clicked on Form2.I mean no duplicate rows must be added.