我有两个网格视图和一个按钮单击按钮我将数据从 gridView1 复制到 gridView2 这是我的代码:
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;
}
};
}
}
}
我想更改与条件不匹配的 gridView1 行的背景颜色,以便我可以验证它们
不幸的是,所有行都变为红色。
我该如何解决这个问题。
提前致谢