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.
Unfortunately, activation email could not send to your email. Please try again.

Problem with BeginUpdate()

Thread ID:





16712 Jul 22,2004 08:17 AM Feb 10,2005 01:16 PM Windows Forms 8
Tags: GridControl
Kewalramani Kanchan
Asked On July 22, 2004 08:17 AM

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.

Administrator [Syncfusion]
Replied On July 22, 2004 09:09 AM

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.

Administrator [Syncfusion]
Replied On February 3, 2005 11:32 AM

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.

Administrator [Syncfusion]
Replied On February 3, 2005 12:08 PM

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

Administrator [Syncfusion]
Replied On February 3, 2005 04:25 PM

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

Administrator [Syncfusion]
Replied On February 4, 2005 10:43 AM

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

Administrator [Syncfusion]
Replied On February 4, 2005 01:49 PM

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

Administrator [Syncfusion]
Replied On February 4, 2005 04:49 PM

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

Administrator [Syncfusion]
Replied On February 10, 2005 01:16 PM

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


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.

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.