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.

Render To Graphic instead of to grid

Thread ID:

Created:

Updated:

Platform:

Replies:

24710 Feb 9,2005 12:09 PM Feb 11,2005 11:50 AM Windows Forms 5
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On February 9, 2005 12:09 PM

Is there a way to have the renderer of a cell render to a graphics object instead of/ or in addition to the grid. I really tried to insert some code into the query cell info, but it called QueryCellInfo again (recursivly) in response to the CreateRenderer renderer call. Any ideas about how to render the cell image into a Graphics object when I already have the complete GridStyle object?

Administrator [Syncfusion]
Replied On February 9, 2005 01:02 PM

We use following code in our grouping grid for dragging headers with showing a image of the header cell in it: private Bitmap CreateHeaderBitmap(int rowIndex, int colIndex) { Graphics g = null; Size size = new Size(GridGroupDropArea.GetColWidth(colIndex), GridGroupDropArea.GetRowHeight(rowIndex)); Rectangle bounds = new Rectangle(Point.Empty, size); GridStyleInfo style = GridGroupDropArea.Model[rowIndex, colIndex]; GridCellRendererBase headerCellRenderer = grid.CellRenderers[style.CellType]; Bitmap bm = new Bitmap(size.Width, size.Height); try { g = Graphics.FromImage(bm); BrushPaint.FillRectangle(g, bounds, style.Interior); headerCellRenderer.Draw(g, bounds, rowIndex, colIndex, style); } finally { if (g != null) g.Dispose(); } return bm; } Stefan >Is there a way to have the renderer of a cell render to a graphics object instead of/ or in addition to the grid. > >I really tried to insert some code into the query cell info, but it called QueryCellInfo again (recursivly) in response to the CreateRenderer renderer call. > > >Any ideas about how to render the cell image into a Graphics object when I already have the complete GridStyle object?

Administrator [Syncfusion]
Replied On February 10, 2005 11:49 AM

Why do i have in fact to go throught the model ? Can i directly draw the cell ? I feel like there is the : Grid -- GridModel -- MyDataSorted - Mydata Isn''t it too much ?

Administrator [Syncfusion]
Replied On February 10, 2005 06:55 PM

All you need is: 1) Get the bounds, e.g. grid.RangeInfoToRectangle 2) Get the style, e.g. Model[row, col] 3) Get the renderer: grid.CellRenderers[style.CellType] 4) call renderer.Draw, e.g. headerCellRenderer.Draw(g, bounds, rowIndex, colIndex, style); Stefan >Why do i have in fact to go throught the model ? >Can i directly draw the cell ? > >I feel like there is the : >Grid -- GridModel -- MyDataSorted - Mydata > >Isn''t it too much ?

Administrator [Syncfusion]
Replied On February 11, 2005 09:42 AM

I tried the code but got the following error... at Syncfusion.Windows.Forms.Grid.GridCellRendererBase.DrawBackground(Graphics g, Rectangle rect, GridStyleInfo style, Boolean fillBackground) at Syncfusion.Windows.Forms.Grid.GridCellRendererBase.Draw(Graphics g, Rectangle cellRectangle, Int32 rowIndex, Int32 colIndex, GridStyleInfo style) Any idea ? The only difference is that i created a style from scractch instead of using the model...

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

If you create the style from scratch be sure to associate the style object with a GridStyleInfoIdentity object with correct row index and column index. Stefan >I tried the code but got the following error... > > >at Syncfusion.Windows.Forms.Grid.GridCellRendererBase.DrawBackground(Graphics g, Rectangle rect, GridStyleInfo style, Boolean fillBackground) > at Syncfusion.Windows.Forms.Grid.GridCellRendererBase.Draw(Graphics g, Rectangle cellRectangle, Int32 rowIndex, Int32 colIndex, GridStyleInfo style) > >Any idea ? >The only difference is that i created a style from scractch instead of using the model... >

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.

;