繁体   English   中英

如何将一个单元格值也复制到其他单元格?

[英]how can i copy one cell value to other cells also?

我想将内容从一个单元格复制到同一列中的其他单元格,所以我想将聚会的名称复制到其他单元格,直到像绿色一样变回绿色​​。

在此处输入图片说明

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++;
}
 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;
      }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM