我想将内容从一个单元格复制到同一列中的其他单元格。所以我想将该方的名称复制到其他单元格中,最后返回颜色为绿色,如明智的
if (dataGridView1.Rows[j].DefaultCellStyle.BackColor == System.Drawing.Color.Yellow)
{
int nextRowIndex = j + 1; // the code works up to one cell.
var value = dataGridView1.Rows[j].Cells[2].Value.ToString();
dataGridView1.Rows[nextRowIndex].Cells[2].Value = value;
nextRowIndex++;
}
答案 0 :(得分:0)
if (dataGridView1.Rows[j].DefaultCellStyle.BackColor ==System.Drawing.Color.Yellow)
{
int nextRowIndex = j + 1; // the code works up to one cell.
while (dataGridView1.Rows[nextRowIndex].DefaultCellStyle.BackColor == System.Drawing.Color.Green)
{
dataGridView1.Rows[nextRowIndex++].Cells[2].Value = dataGridView1.Rows[j].Cells[2].Value;
}
}