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
close icon

RefreshRange causing entire grid to repaint

I have some code that makes some changes in how a group of rows might be drawn. I execute a RefreshRange, in this case, for 3 rows, rows 150-152. But then the grid gets the OnPaint call, the ClipRectangle is for the entire grid. Why is that? I would expect the clip rectangle to only cover the rows that were refreshed. The specific call is: Debug.WriteLine("Refreshing rows " + firstRow.ToString() + " to " + lastRow.ToString()); RefreshRange(GridRangeInfo.Rows(firstRow, lastRow)); The debug output is: Refreshing rows 150 to 152 This is the call stack from OnPaint in my derived grid class: Depth: 0 - Method: MozartGridBase.DumpStack Depth: 1 - Method: MozartGridBase.OnPaint Depth: 2 - Method: Control.PaintWithErrorHandling Depth: 3 - Method: Control.WmPaint Depth: 4 - Method: Control.WndProc Depth: 5 - Method: ScrollControl.WndProc Depth: 6 - Method: GridControlBase.WndProc Depth: 7 - Method: MozartGridBase.WndProc Depth: 8 - Method: ControlNativeWindow.OnMessage Depth: 9 - Method: ControlNativeWindow.WndProc Depth: 10 - Method: NativeWindow.DebuggableCallback Depth: 11 - Method: SafeNativeMethods.UpdateWindow Depth: 12 - Method: Control.Update Depth: 13 - Method: GridControlBase.Update Depth: 14 - Method: MozartGridBase.Update Depth: 15 - Method: GridControlBase.RefreshRange Depth: 16 - Method: MozartGrid.SetTreeRowSelection Depth: 17 - Method: CheckBoxHeaderRenderer.EditCheckBoxCheckStateChanged Depth: 18 - Method: CheckBox.OnCheckStateChanged Depth: 19 - Method: CheckBox.set_CheckState Depth: 20 - Method: HeaderCheckBox.OnClick Depth: 21 - Method: CheckBox.OnMouseUp Depth: 22 - Method: MozartCheckBox.OnMouseUp Depth: 23 - Method: Control.WmMouseUp Depth: 24 - Method: Control.WndProc Depth: 25 - Method: ButtonBase.WndProc Depth: 26 - Method: MozartCheckBox.WndProc Depth: 27 - Method: ControlNativeWindow.OnMessage Depth: 28 - Method: ControlNativeWindow.WndProc Depth: 29 - Method: NativeWindow.DebuggableCallback Depth: 30 - Method: UnsafeNativeMethods.DispatchMessageW Depth: 31 - Method: ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop Depth: 32 - Method: ThreadContext.RunMessageLoopInner Depth: 33 - Method: ThreadContext.RunMessageLoop Depth: 34 - Method: Application.Run Depth: 35 - Method: Form1.Main Painting - ClipRect({X=0,Y=19,Width=696,Height=453}) There is actually nothing happening in my Update() override, it just calls base.Update() at the moment. It''s really just there as a convenient place to place a breakpoint for some stuff I''ve been testing. Obviously, all the checkbox stuff is our code, but it''s at Depth 16 that the RefreshRange call above is made. Should I be calling something besides RefreshRange()? Pete

5 Replies

AD Administrator Syncfusion Team September 13, 2005 09:48 PM UTC

A few additional notes, the "Painting - ClipRect..." stuff is from my OnPaint override. Also, the reason Y begins at 19 is we''ve actually adjusted the internal GridBounds top down 19 pixels because we draw a header in the area above it. But otherwise, that''s the width and height of the grid in the cliprect.


AD Administrator Syncfusion Team September 14, 2005 01:52 PM UTC

Sorry to bring this back up to the top, but I''ve got a tight deadline and this is a pretty serious performance issue for us. It''s basically causing the entire grid to redraw when we really only need a few rows redrawn. Thanks.


AD Administrator Syncfusion Team September 14, 2005 03:10 PM UTC

If you put a stop in RefreshRange, can you step through our code to see exactly why the passed in range is being extended to be the visible grid? There are special situations where a rectangle is enlrged to be the whole grid. (For rxample when colwidths are changing). I think if you step through the code, you may be able to spot the exact text that is enlarging teh range, and this may give some hints on how to avoid it.


AD Administrator Syncfusion Team September 14, 2005 05:56 PM UTC

Clay, I believe I''ve tracked down the problem when I removed my RefreshRange() call and the same OnPaint was happening for the entire grid. I guess I need to explain in a bit more depth what''s going on and maybe you can help me find a solution. We have a custom checkbox render/model (with custom checkbox control) in our first column. We use this for selecting/deselecting rows in the grid. Checking a selection checkbox can possibly select rows other than the one with the checkbox. This is all handled through logic which then modifies content of GridControl.Selections. It appears that somewhere in here (I believe in the call to PaintSelectCells.UpdateSelectRange()), the paint range of the paint is being set. In the first case, the initial GridControl.Selections is empty. If I click a certain selection checkbox, for example, it might add two rows to the selection. My thinking is, only these two rows should be redrawn, but the OnPaint, as mentioned earlier, is getting a clipping rectangle for the entire grid. I can''t be positive this is where it''s coming from. Since there''s no way to really see where the WM_PAINT message is being sent from (or is there?) I''ve just had to trace through to see where the possible places are. Thanks. Pete


AD Administrator Syncfusion Team September 14, 2005 06:14 PM UTC

Nevermind. Further tracing led me right back into my code where I have an Invalidate() call that shouldn''t be there. My mistake. I apologize for the wasted time.

Loader.
Live Chat Icon For mobile
Up arrow icon