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.

Optimization

Thread ID:

Created:

Updated:

Platform:

Replies:

31921 Jul 18,2005 02:53 PM Jul 19,2005 02:01 PM Windows Forms 8
loading
Tags: GridControl
Martin Cyr
Asked On July 18, 2005 02:53 PM

I''d like to know if there is any way to optimize the drawing of the grid in the following project (last post) http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=31431 The grid isn''t that bad in this particular project, but in the real thing, with the data access it''s even more sluggish.

Administrator [Syncfusion]
Replied On July 18, 2005 03:18 PM

Putting a UserControl in every cell using GridGenericCellRenderer is costly. Every time a static cell is drawn, the user control is situated off-screen, and a bitmap snapshot is taken, and then this bitmap is then drawn on screen. If you could statically draw what you want to see (couple of rectangles with some text in them) instead of using the base class GridGenericCellRenderer when the cell is not active, I think things would speed up. You could test this out just by calling GridStaticCellRenderer.DrawText instead of calling the baseclass in the static case. This would give you an idea of how much drawing the usercontrol off screen is costing.

Martin Cyr
Replied On July 18, 2005 04:45 PM

Great idea. Seems to change everything from what I just tested! Do you know of any helper functions to DrawText with style (on two lines, horizontally and vertically centered)?

Martin Cyr
Replied On July 18, 2005 05:30 PM

Did you mean that I should not use grid in cells? That I should simply draw two lines in each cell (diving it in 4) and then draw text in each of the corners?

Administrator [Syncfusion]
Replied On July 18, 2005 06:00 PM

The idea would be to avoid calling the baseclass code to do the drawing for the static path through renderer.Ondraw. You can use the shared method, GridStaticCellRenderer.DrawText method to draw the text. You can call e.Graphics.DrawLine to draw the lines you want to see. Doing it this way is more efficient than using the baseclass call that does the bitmap technique to display an arbitary usercontrol. (If you usercontrol was more involved, then this static drawing might not be an option, but it looks like you just has simple texboxes which should be simple to draw. You can still use the GridInCell for the active drawing of the cell as there will only be one at most of these cells being used at any one point. All the other cells will be using the static drawing code.

Martin Cyr
Replied On July 19, 2005 08:25 AM

I think that you''re right. Is there a way to specifiy that the CellType for the active cell is different than the others (is there a BaseStyle for something like that) or should I change it in the OnDraw, or the CellMoving?

Administrator [Syncfusion]
Replied On July 19, 2005 09:01 AM

I would try handling it in OnDraw. Normally there are 2 paths through this method. One for drawing the active cell, and the other for drawing the non-active cell. So, in your current code, add a method that draws the non-active cell and call this method from OnDraw where you want to draw the nonactive cell, and do not call the baseclass in this case as calling the baseclass will trigger the bitmap technique. (Or you could just put this drawing code directly in OnDraw and avoid the extra method call).

Martin Cyr
Replied On July 19, 2005 09:09 AM

Ok, but I then keep that code in my CellRenderer class that is based on the GridGenericControlCellRenderer? I tried to do another class based on GridStaticCellRenderer but it never invoke CreateRenderer so I''m confused on what to do with it. I''ll try it in the OnDraw then, thanks.

Martin Cyr
Replied On July 19, 2005 02:01 PM

Again, thanks a lot Clay, it works just great! Just in case it''s usefull to anyone, I''ll post the new thing again. It''s a grid with each cell subdivided in 4. The active cell is an embeded grid. This grid contains usercontrols: one active, and one static repainted as needed. All optimized as much as I could. It''s neat I think now. GridEmbeded-Sample_9426.zip

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.

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.

;