Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
575
Troubleshooting using WinGrid with BindingNavigator
posted

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

Parents
  • 469350
    Offline posted

    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.

Reply Children