Hi,
I am using UltraGrid with a BindingNavigator. When adding a new record with the BindingNavigator AddNewItem button I would like to supply default values to two cell in the new record. I have gotten this to work by using the AfterCellActivate event, it works but doesn't seem correct. I tried to initialize the default values with the grid but this didn't work.
After I edit the new row I want to validate the data when saving the changes with the BindingNavigator SaveItem button. I tried to run my code in the AfterRowInsert and AfterRowUpdate event, but they didn't fire. I can validate the data in the SaveItem code but unless I move the focus off the last cell in the new record to a different cell in the new record the code that tests the cell see that last value as DBNull.
Thanks for the Help
Adam
The grid commits the values to the underlying data source based on the UpdateMode property. My guess is that the BindingNavigator is like a toolbar and it's buttons do not take focus. So since the user never leaves the last cell and the grid is not losing focus, the cell stays in edit mode and doesn't get committed.
This is easy enough to resolve. When the user clicks a button the BindingNavigator, you can use the grid's PerformAction method to exit edit mode and then call grid.ActiveRow.Update or grid.UpdateData.
OK,
I have checked the values via the in the BindingNavigators SaveItem code, prior to EndEdit. But in this case I run into the problem that the last cell value added doesn't seem to be committed to the grid. When the grid loses focus I should be able to run a command to commit the last value so that my code doesn't see it as DBNull.
Thanks
AfterRowInsert and AfterRowUpdate only fire when the user inserts or updates a row through the grid. If you are doing this through the BindingNavigator, then you would have to use some event of the BindingNavigator itself or perhaps the DataSource.