Scenario: I have a form with one grid, one tableAdapter, one bindingSource and one bindingNavigator. I simply drag and drop the controls in the form, and I assigned the DataSource of this grid to the bindingSource.
The last column of my grid is a string field, that do not allow null values.
I fill al the fields of one row, I typed a value in the last column but it has still the focus.
I click "Add new" button of the Navigator bar, and I receive an error: "Field xxxx do not allow null values".
is there a way to use bindingNavigator without changing the std. functionallity, or must I write a handle for every action Add, Save, etc... ?
Thanks
Hi,
I tried this out and I get the same results.
The problem is that the BindingNavigator is like a toolbar - it doesn't take focus away from the grid. Since the grid never loses focus, it doesn't know that the user is done editing the current cell and so the changes to that cell don't get committed. If you clicked on a button control or any other control that takes focus from he grid, it would work okay
You can work around this, to some extent, by trapping for when the user clicks on the BindingNavigator and attempting to commit any pending changes in the grid.
private void bindingNavigator1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { this.ultraGrid1.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.ExitEditMode); }
I say "for the most part", because I don't see any way to cancel a BindingNavigator action. So if the call to PerformAction fails (if you leave the field null, for example), you will still get an exception. But I guess in that case, this would be correct.
Hi Mike.
This is what i thought.
Do you think is better to use: .ExitEditMode than Grid.UpdateData ?
Thansks.
Same problem using MoveFirt, Prev, Next, Last.
Is there a way to know when a row enter in EditMode ?
I could disable the rest of the buttons less Ok, Cancel, while the grid is in EditMode.
Ok Mike, thanks for your help.
It won't make much difference in this case. UpdateData will cause the current cell to exit edit mode, so that will fix the issue.
It will also commit any pending changes from any row in the grid.
In this scenario, you only the current row can possibly have any pending changes - unless you are updating data in code - and the current row's changes will get committed anyway, because the BindingNavigator is already handling this (probably by calling EndEdit) which is why you were getting an error in the first place, because the row was being committed by the BindingNavigator before the cell exited edit mode.
So calling UpdateData will commit the current row before the BindingNavigator has a chance to do it. If this fails, the BindingNavigator will end up trying to do it again and this will might have undesirable results - especially since you can't cancel the BindingNavigator's processing. So I would stick with ExitEditMode.