How to remove focus from the Infragistics ultragrid cell when clicking outside?

Vibgy picture Vibgy · Jul 5, 2012 · Viewed 7.5k times · Source

I have an infragistics ultragrid control in a windows form. There is an 'Add New' button outside to insert new rows to the grid.

The problem I faced is, when I click the button outside the grid, while I'm editing a cell inside the grid, the cell doesn't lose focus. Because of this the edited new value is not updated to its underlying data source.

I need this cell to lose focus and update it's underlying data source, because the 'Add New' button creates a new row with this particular column having a default value which is calculated based on the previous row's edited value.

So any ideas on how to unfocus the ultragrid cell? This situation may apply to normal GridView also.

Answer

alhalama picture alhalama · Jul 5, 2012

If your button is on a Toolbar, then the behavior you are seeing is expected because toolbars don't take focus. If this is the case before performing your logic you can use the PerformAction method of the grid and pass in UltraGridAction.CommitRow to force the row that was being editor to commit its updates.

For example:

this.ultraGrid1.PerformAction(UltraGridAction.CommitRow);