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
I think (I'm not sure, though), that you're trying to insert a row after the New Row...which is not possible. Changing your code to this
myGrid.Rows.Insert(e.RowIndex - 1, 1);
Should insert the row before the New Row, which should work.
Here I got the solution
myGrid.NotifyCurrentCellDirty(true);
I am working on winforms DataGridView. In my case i tried @iSid solution, but here is an aid in that, i tried this
myGrid.NotifyCurrentCellDirty(true);
myGrid.NotifyCurrentCellDirty(false);
By only making current cell dirty in not working, you have to commit that cell also. In the next command i am flagging the current cell is not dirty, this will enforce datagridview to add a dirty row. It is working in my project.
This is really really late considering the question timeframe, but the accepted answer did not work for me. What ended up resolving it for me was first inserting a row above the dirty row, then editing that 'clean' row instead.
if (e.RowIndex == myGrid.Rows.Count - 1)
{
myGrid.Rows.Add();
}
myGrid[e.ColumnIndex, e.RowIndex].Value = etd.ResultText; // Edit at your leisure.