I have two grid view and a button on a click of button I copy data from gridView1 to gridView2 This is my code:
private async void btnAdd_Click(object sender, EventArgs e)
{
int[] selectedRows = gridView1.GetSelectedRows();
for (int i = 0; i < selectedRows.Length; i++)
{
DataRow rowGridView1 = (gridView1.GetRow(selectedRows[i]) as DataRowView).Row;
for (int j = 0; j < gridView3.RowCount; j++)
{
if (rowGridView1["BS"].ToString() == gridView3.GetRowCellValue(j, "ProjectN").ToString() &&
rowGridView1["Repère"].ToString() == gridView3.GetRowCellValue(j, "Parts").ToString())
{
DataRow row = dt.NewRow();
row[0] = rowGridView1["BS"];
row[1] = gridView3.GetRowCellValue(j, "Parts");
row[2] = gridView3.GetRowCellValue(j, "Profile");
row[3] = rowGridView1["Quantité"];
dt.Rows.Add(row);
}
else if(j == (gridView3.RowCount -1))
{
gridView1.RowStyle += (senderr, ee) => {
if (gridView1.GetFocusedDataRow() == rowGridView1)
{
ee.Appearance.BackColor = Color.Red;
ee.HighPriority = true;
}
};
}
}
}
I want to change the back color of gridView1 rows that do not match the condition so i can verified them
Unfortunately, all rows become red.
how can I fix this problem.
Thanks in advance