簡體   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