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
935
How to prevent button click event when grid fails to validate
posted

I am trying to prevent a button click method from executing when grid errors prevent focus change. When the grid has an error, I retain EditMode and the grid retains focus. However, the button click event still executes. The call stack indicates the focus change has triggered the grid.validating event which is cancelled and as expected the focus is retrieved to the grid. However then the MouseUp event seems to proceed and trigger the Button Click event.

I have an ultraGrid control nested in a user control nested in a second user control that also contains various buttons. I use IDataErrorInfo methods to show the error glyph when the cell is in error and retain EditMode. I have attached an event handler for both grid.Validating and the interior userControl.validating both set to cancel with an error. The user control has AutoValidate.EnablePreventFocusChange. I can't find a similar type of property for the ultraGrid. The buttons are set with AcceptsFocus, CausesValidation.

If i just use nested UserControls, set PreventFocusChange and cancel validation, the button click doesn't happen. It seems related to the state of the most nested container control.

Any suggestions appreciated.

Wendy