Hi
I have a WinGrid that is bound to a BindingSource and has an 'add row' at the bottom of the entries. I am instantiating a new object in the BindingSource's AddingNew when a new object is required.
If the user has entered the Add Row but has not made any changes, when they click or tab away, the data in the row is cleared and the row is blank again. In normal operation, this works beautifully and is exactly the behaviour I want for the application.
My problem is that the form's 'Save' button is on the UltraToolbarsManager toolbar. If the focus is on the unmodified Add Row when 'Save' is clicked, the Add Row does not disappear in the normal way and the app attempts to save the empty row.
I know that clicking a toolbar button does not normally take focus or cause validation. I have tried moving focus in code with a SelectNext, which does get around the problem but I don't like this as a solution and wondered if there was a setting that I could use that would improve things. We are forcing validation of the active control on toolbar_click so if we could somehow make use of this, that would be good.
Thanks in advance.
Are you calling UpdateData on the grid? You need to do this in your ToolClick event, anyway. Otherwise, changes made to an existing row will not be committed. Calling UpdateData should cancel the AddRow in the same way as losing focus on the grid does.
Hi Mike
I'm using 2008 vol 3 (version 8.3.20083.2039 of Infragistics2.Win.UltraWinGrid.v8.3.dll).
The new row is saved into the underlying datasource regardless of whether I click on the ToolBar button. Once the row exists in the grid, it also exists in the datasource. What happens on lost focus, is that this row is removed from the underlying datasource, which is the bit thatisn't happening when I click the ToolBar button.
Hi,
Just to be clear, you are saying that if the focus is on the TemplateAddRow in the grid and you click your ToolBar button, which presumably calls UpdateData on the grid, the row gets saved to the underlying data source - even though not changes have been made to it?
That doesn't sounds like correct behavior to me. What version of the grid are you using? Do you have the latest service release?