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

Problem with BeginUpdate()

Hi Clay: I have a dataset with about 138 columns and hundreds of rows. If I use BeginUpdate() to prevent the flickering of the screen while displaying the DBG the application gives an error and hangs. Commenting the BeginUpate() and EndUpdate() populates the data. Another problem is that whenever there is an error encountered within BeginUpdate() and EndUpdate() the application doesnot display the error to the user. To see the error message we need to hit the Alt key or debug the application. Could you kindly suggest. Thanks for your support, your prompt response is greatly appreciated.

8 Replies

AD Administrator Syncfusion Team July 22, 2004 01:09 PM UTC

Are there multiple threads involved in what you are doing? If so, all code that access teh grid needs to be protected with grid.InvokeRequired checks following by grid.Invoke calls if necessary. If you are populating the datasource while it is bound to the grid, then you may want to call grid.Binder.SuspendBinding and grid.Binder.ResumeBinding to avoid the grid trying to respond to binder events when it serves no purpose. Who is catching the error that you are seeing? Is it your code or the framework code? If it is your code, you can call grid.CancelUpdate to avoid the problem of trying to show a message when there is an open grid.BeginUpdate call pending. If you can post more information on the problem (call stack, exact wrror, etc) or if you can attach a sample project showing the problem, we might be able to suggest something.

AD Administrator Syncfusion Team February 3, 2005 04:32 PM UTC

I am having problem with BeginUpdate as well, whenever I use BeginUpdate/EndUpdate, my application is frozen. This is something that I do, grid.BeginUpdate(); // Remove the rows and add new rows // do some more update grid.EndUpdate(); My application is not a pure .NET application, it is a mixed between C++ and C#, by using com interop. The application hangs when it is trying to access an object that looks to be invalid in my application. If I don''t use BeginUpdate and EndUpdate, everything works. Can you provide any suggestion? Any help will be great. Thanks.

AD Administrator Syncfusion Team February 3, 2005 05:08 PM UTC

Hi Clay, One time, I had the same problem. We are are running also a C++ application(7.1) in mixed mode. for accessing to the blocked fields of Outlook, we''re using the Redemtion.dll component. This is a COM component. When I''m calling a property of this component inside the Begin/EndUpdate, the application is hanging. Regards, Thomas

AD Administrator Syncfusion Team February 3, 2005 09:25 PM UTC

Thomas and Patrick, Try setting ScrollControl.DiscardPaintMessagesAfterBeginUpdate = true; When you call BeginUpdate(), the control by default does not handle WM_PAINT messages. Only once you call EndUpdate they will be processed. If this causes problems in your application, you can set this static property to True. In such cases, WM_PAINT messages will be simply discarded and any invalid regions will be validated. There is one problem with this approach: If a screen region is marked invalid, the WndProc will be repeatedly called with WM_PAINT at the the top of the WndProc until EndUpdate is called. This can cause your application to freeze if another window gets created or if you make a web service call and WndProc messages need to be processed. Setting DiscardPaintMessagesAfterBeginUpdate = True will help avoid these scenarios. Stefan

AD Administrator Syncfusion Team February 4, 2005 03:43 PM UTC

Hi Stefan, I can''t find DiscardPaintMessagesAfterBeginUpdate anywhere in the grid control class. I am using version 2.0. thanks, Patrick

AD Administrator Syncfusion Team February 4, 2005 06:49 PM UTC

Hi Stefan Thanks for the update. I''ll try to set this property and check the result. I''ll update this post as soon I have any results. Regards Thomas

AD Administrator Syncfusion Team February 4, 2005 09:49 PM UTC

Patrick, this property was added after version 2.0. With earlier versions, you could try and get similar behavior by overriding WndProc, e.g. protected override void WndProc(ref Message msg) { if (msg.Msg == WM_PAINT && Updating) { PAINTSTRUCT ps = new PAINTSTRUCT(); BeginPaint(Handle, ref ps); EndPaint(Handle, ref ps); msg.Result = IntPtr.Zero; return; } base.WndProc(ref msg); } [StructLayout(LayoutKind.Sequential)] public struct PAINTSTRUCT { // Fields public IntPtr hdc; public bool fErase; public int rcPaint_left; public int rcPaint_top; public int rcPaint_right; public int rcPaint_bottom; public bool fRestore; public bool fIncUpdate; public int reserved1; public int reserved2; public int reserved3; public int reserved4; public int reserved5; public int reserved6; public int reserved7; public int reserved8; } [DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true, CallingConvention=CallingConvention.Winapi)] public static extern IntPtr BeginPaint(IntPtr hWnd, ref PAINTSTRUCT lpPaint); [DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true, CallingConvention=CallingConvention.Winapi)] public static extern bool EndPaint(IntPtr hWnd, ref PAINTSTRUCT lpPaint); internal const int WM_PAINT = 15; // 0x000f Stefan

AD Administrator Syncfusion Team February 10, 2005 06:16 PM UTC

Stefan, My application doesn''t hang any more. Thanks for the help.

Live Chat Icon For mobile
Up arrow icon