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
155
How to cancel click event based on certain condition.
posted

I have a situation in which a user can click a row and change data for that row, which will change a Boolean indicating the code has been changed. Then when the user clicks a new row, the click event should check to see if CodeChanged = true, if so, then a messagebox will pop-up asking the user if they would like to save unsaved data. If they click yes then the click event should be cancelled and the previously selected row should stay selected. What is the best way to go about doing this?

Parents
  • 2165
    posted

    Hello Devin,

    Thank you for the detailed description. Based on it I managed to create a simple sample reproducing your scenario.

     

    In order to prevent the current row to be unselected due to some actions you could use BeforeRowDeactivete event, as Mike suggested. By using the Cancel property of the CancelEventArgs you could prevent the active row to be deactivated. Thus you could achieve the desired functionality instead of using the Click event.

    I’ve implemented this suggestion in a simple sample, and you could run and evaluate it, please see attached zip.

     

    Please let me know if you have any further questions.

    CAS-143946-N9Y6Z9.zip
Reply Children