How to handle the activating or deactivating the current cell exception in WinForms GridControl?
Steps for handle the exception
When you try to add a row to the GridControl, it resets the CurrentCell that causes a problem at the middle of activating or deactivating the CurrentCell.
You can avoid this by working directly with the grid’s GridData object.
//add the row this.gridControl1.Model.Data.RowCount += 1;
'add the row Me.gridControl1.Model.Data.RowCount += 1
You can also achieve this by locking the CurrentCell before incrementing the RowCount and unlock after that.
//lock and unlock the cell while add the row this.gridControl1.CurrentCell.Lock(); this.gridControl1.RowCount += 1; this.gridControl1.CurrentCell.Unlock();
'lock and unlock the cell while add the row Me.gridControl1.CurrentCell.Lock() Me.gridControl1.RowCount += 1 Me.gridControl1.CurrentCell.Unlock()