We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

RemoveRange and MessageBox in Update block cause hang

Thread ID:

Created:

Updated:

Platform:

Replies:

15011 Jun 9,2004 05:24 PM UTC Jun 10,2004 10:43 AM UTC WinForms 4
loading
Tags: GridControl
Greg Wright
Asked On June 9, 2004 05:24 PM UTC

I having some issues with displaying a message box within a BeginUpdate/EndUpdate block. Any of the following cause the app to hang once it reaches the MessageBox.Show line. Ex. #1 this.gridControl1.BeginUpdate(); // If the RemoveRange is removed, it doesn''t hang this.gridControl1.Rows.RemoveRange(2, 2); MessageBox.Show("Testing."); this.gridControl1.EndUpdate(); Ex. #2 - Same as Ex. #1, but in a try block w/ MessageBox in catch try { Cursor.Current = Cursors.WaitCursor; this.gridControl1.Model.BeginUpdate(); this.gridControl1[1, 1].Text = "1,1"; this.gridControl1.Rows.RemoveRange(2, 2); throw new Exception("This is a test exception."); } catch (Exception e1) { MessageBox.Show(e1.Message); } finally { this.gridControl1.Model.EndUpdate(); this.gridControl1.Model.Refresh(); Cursor.Current = Cursors.Arrow; } Ex. #3 - Uses the Invalidate option on BeginUpdate. Differs from other examples in that RemoveRange doesn''t even have to be called. Will hang just by changing a cell value. try { Cursor.Current = Cursors.WaitCursor; this.gridControl1.BeginUpdate(BeginUpdateOptions.Invalidate); this.gridControl1[1, 1].Text = "1,1"; throw new Exception("This is a test exception."); } catch (Exception e1) { MessageBox.Show(e1.Message); } finally { this.gridControl1.EndUpdate(true); Cursor.Current = Cursors.Arrow; } Am I doing something wrong, or is this an issue. I am using version 2.0.5.1. Thanks, Greg

Administrator [Syncfusion]
Replied On June 9, 2004 05:43 PM UTC

You will not be able to display a messagebox while a grid.BeginUpdate is open. You might try calling grid.CancelUpdate before you try to display the message. Or, depending upon where this code is located (whether it is part of the current cell deactivate/activate cycle), you may be able to display an error message just by setting grid.CurrentCell.ErrorMessage. If this string is not empty, the grid will display it at a safe point in the deactivate/activate cycle. Or, another option would be to set a flag in your code where you are now trying to display the messagebox, and then check that flag and display the messagebox after your call to EndUpdate if necessary.

Greg Wright
Replied On June 9, 2004 05:54 PM UTC

Clay, Thanks for the quick response. If you wouldn''t mind, could you give me a little more detail as to why a messagebox can''t be displayed while a BeginUpdate is open so I can have a better understanding? I have done it without any problems, except for this one, where RemoveRange is called prior to displaying the messagebox. Thanks, Greg

Administrator [Syncfusion]
Replied On June 9, 2004 06:51 PM UTC

If the grid is in Update mode then WM_PAINT messages are not being handled in WndProc, and this causes a lockup in this case. The grid tries to listen to WM_KILLFOCUS message and call CancelUpdate in WndProc to avoid this problem, but that only works in 50% of cases. Explicitly calling CancelUpdate before you try displaying the MesageBox may work for you.

Greg Wright
Replied On June 10, 2004 10:43 AM UTC

Thanks Clay. >If the grid is in Update mode then WM_PAINT messages are not being handled in WndProc, and this causes a lockup in this case. > >The grid tries to listen to WM_KILLFOCUS message and call CancelUpdate in WndProc to avoid this problem, but that only works in 50% of cases. > >Explicitly calling CancelUpdate before you try displaying the MesageBox may work for you.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;