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
1600
CausesValidation = False does not prevent grid from showing a validation error.
posted

I am trying to prevent the WinGrid from showing an error message when the user enters invalid data into a cell and then clicks the Cancel button on my form.  To accomplish this, I tried setting the CausesValidation property of the button to False.  This did not work because the actual validation of that cell does not occur within the Validate event of the grid control.

 Since I can't use the CausesValidation property to prevent the error message from being displayed, is there any other way in which I can allow the grid to show the error message when the user clicks in another location, but don't show the error message when the user clicks the Cancel button on my form?

Parents
No Data
Reply
  • 469350
    Offline posted

    Hi,

    I don't know if what you are asking for is possible. You are correct that CausesValidation will not work here.

    The grid's UpdateMode property determines when it tried to commit the value of a cell to the underlying data source. The question is, what exactly do you want to happen when the user clicks the Cancel button? All the grid knows at this point is that it is losing focus. It doesn't know that it's losing focus because a cancel button was clicked. It could be losing focus for any reason - the user could be clicking a save button or just moving to another control on the form. By the time the button click event fires, it will already be too late and the grid will have lost focus. So you really can't base what happens in the grid on what was clicked outside the grid. 

    If yu just want to cancel the error messages displayed by the grid, you can do this in the Error or CellDataError events of the grid. There are properties on the event args to allow you to choose whether or not the error messages are displayed. But cancelling the display of the error message doesn't prevent an error from actually occurring, so I'm not sure what will happen or what you want to happen beyond that. 

Children