Hi,
I am testing out an ultragrid on a winform. The ultragrid is bound to a datatable using dataset/tableadapter (wizard).
When I click the BindingNavigators save button my added row is only saved if I first move the cursor from the new row onto another row in the grid.
How can I change this setting/behavior?
The bindingsource.endedit method is called when the BindingNavigator save button is clicked, but it does not appear to have an effect if the cursor still is in the new grid row.
Thanks,
Kai
UltraGridRow aRow = grdForm.Rows[i]; if (aRow.IsUnmodifiedTemplateAddRow) { aRow.Update(); }
Hi Kai,
CommitRow is an action that I think it only intended to apply to the TemplateAddRow. So it may work, but I'm honestly not sure if it's the best choice.
I think the inconsistency you are seeing might be my fault. The code I posted here was wrong. Instead of grid.Update(), it should be grid.UpdateData(). The former just tells the grid to paint. The latter tells it to commit the changes. Sorry about the confusion.
Thanks Mike,
At first your suggestion seemed to do the trick, but after some testing the improvement appeared incosistent.
I however tried:PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.CommitRow) which seems to help completely.
Is there any obvious untowards effects of "commitrow" that I should expect?
Regards,
The grid commits the changes to the underlying data source based on the UpdateMode property. By default, it happens when the grid loses focus or changes rows. You can change this property to also include changing cells.
But I expect that your navigator doesn't take focus and therefore the grid is not losing focus and so the current cell in edit mode doesn't get committed. So what you probably need to do is something like this:
grid.PerformAction(ExitEditMode);
grid.Update();