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. Image for the cookie policy date

GridControl BeginUpdate/EndUpdate

Hello, I have a substantial amount of modifications to make to individual cells within my GridControl object. If I do not make a call to BeginUpdate, the rendering of the grid is very slow. However, if I do call BeginUpdate on the grid, if I have a messagebox or other type of alert that needs to be displayed to the user before the EndUpdate method is called, my app will hang indefinitely with the CPU usage at 100% and the MessageBox will not be shown. If I ensure that I call EndUpdate before displaying my MessageBox, then I don''t have any problems. While this might be acceptable for most of the operations in the grid, if something causes an unexpected error and a alert is shown and I have suspended any updates to the grid, the app will hang and must be restarted altogether. In addition, it would be a real pain to manually call BeginUpdate and EndUpdate at every possible chance where something might need to be displayed. Suggestions?

4 Replies

AD Administrator Syncfusion Team January 31, 2004 10:39 PM UTC

Even if the MessageBox displays OK as the result of some exception, I think you will have to handle that exception to somehow reset the grid so it starts painting again. The BeginUpdate/EndUpdate code ignores WM_PAINT messages to avoid the painting. This is what sets up the endless loop when you try to display a MessageBox while an update is in progress. So, one solution is to include a try-catch in your update code, and in the catch block, cancel or end the update before either rethrowing the exception, or displaying something yourself. Another solution is to use interop to freeze the painting (and not ignore the WM_PAINTs in WndProc). This technique is discussed in one of our WindForms FAQ. http://www.syncfusion.com/faq/winforms/search/637.asp Here is a sample that illustrates both techniques.


AD Administrator Syncfusion Team January 31, 2004 11:50 PM UTC

The second option (freezing the painting) seems to be the easiest to implement but, when I try it, I can''t seem to get the scrollbars of the GridControl to display properly without resizing the window that contains the grid.


AD Administrator Syncfusion Team January 31, 2004 11:50 PM UTC

The second option (freezing the painting) seems to be the easiest to implement but, when I try it, I can''t seem to get the scrollbars of the GridControl to display properly without resizing the window that contains the grid.


AD Administrator Syncfusion Team January 31, 2004 11:55 PM UTC

Nevermind, I included the freeze property into my derived GridControl and was invalidating the grid itself, not the form that contained it. Everything works now, thanks again!

Loader.
Live Chat Icon For mobile
Up arrow icon