Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make new row dirty programmatically and insert a new row after it in DataGridView

I've an editable unbounded datagridview. I'm changing the value of new row programmatically.

Normally, when user types in any field of a new row, it becomes dirty and another new row is inserted below it.

But in my case, when user comes in to any field of a new row, I'm trapping the function key and changing the cell value programmatically.

myGrid.CurrentCell.Value = "xyz";

And it doesn't insert a new row below it.

Now as a work around I tried this on CellValueChanged event handler.

  if (myGrid.NewRowIndex == e.RowIndex)
  {
    myGrid.Rows.Insert(e.RowIndex + 1, 1);
  }

But it throws error saying No row can be inserted after the uncommitted new row..

How could I tell myGrid that I've made current row (which is a new row) dirty and that there is need of a new row after it?

like image 616
IsmailS Avatar asked Dec 21 '10 07:12

IsmailS


1 Answers

Here I got the solution

myGrid.NotifyCurrentCellDirty(true);
like image 85
IsmailS Avatar answered Oct 01 '22 04:10

IsmailS