Memento

Memento

  • NA
  • 111
  • 133.3k

c# winforms DataGridView - how to repeat content of selected cell or cells ?

Jun 2 2012 11:25 AM
How can I copy (repeat) selectedCellsValue - till end of row.
Number of cells (i.e. Columns) in a row - varies (about 30).
Excel have that option named - autoFill - Copy.
Here is my try:
int x = dgv.SelectedCells.Count;
  foreach (DataGridViewCell c in dgv.CurrentRow.Cells)
   {
   if (c.Selected == true)
   {
   string a = c.Value.ToString();
  x = x+1;
  dgv.CurrentRow.Cells[x].Value = a;
  But it copies selectedeCells only once.

Answers (6)