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
1470
MessageBox in BeforeRowDeactivate affecting ClickCell event
posted

Hi there

We using 13.1.20131.2040 of the UltraWinGrid in a VS 2010 .NET 4.0 C# WinForms app.

We are using the grids BeforeRowDeactivate event handler to perform validation and have noticed that the ClickCell event handler is never hit if we place a MessageBox in our validation within the BeforeRowDeactivate event handler.

Even when e.Cancel = false in the BeforeRowDeactivate event handler, if a MessageBox is used in that event handler then the ClickCell event handler is never hit but if we do NOT use a MessageBox then the ClickCell event handler is hit no problem.

What we are trying achieve is to validate/save in BeforeRowDeactivate, the user is prompted to save any unsaved data in that event handler, and if they do NOT wish to save to load child data for the next row in ClickCell

Is there a workaround to this?

Should I be using another event for validation or another event to load the data?

 

Sorry about not having a sample but our app is a pretty big beast and I have not as yet had a chance to create a sample to reproduce.

 

Regards

Geoff

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    Hi Geoff,

    It's not uncommon for a MessageBox shown in certain grid events to interfere with the firing of other events, especialy mouse-related events. Showing a modal dialog takes focus away from the application so the mouse messages can get lost or be handled by the new dialog.

    I'd recommend not showing a MessageBox inside of BeforeRowDeactivate, if you can. If you must do this, then try moving the MessageBox.Show call into a separate method and then using BeginInvoke to show it, instead of showing it from directly inside the event. That will create a delay so that the MessageBox shows after all of the event processing is complete.


            void ultraGrid1_BeforeRowDeactivate(object sender, CancelEventArgs e)
            {
                UltraGrid grid = (UltraGrid)sender;
                grid.BeginInvoke(new MethodInvoker(this.ShowMessageBoxForBeforeRowDeactivate));
            }

            private void ShowMessageBoxForBeforeRowDeactivate()
            {
                MessageBox.Show("Yoho");
            }

Children