![](/img/trans.png)
[英]Gridview copy cell value of a column to all other cells of the column
[英]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.