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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Render To Graphic instead of to grid

Thread ID:

Created:

Updated:

Platform:

Replies:

24710 Feb 9,2005 05:09 PM UTC Feb 11,2005 04:50 PM UTC WinForms 5
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On February 9, 2005 05:09 PM UTC

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 06:02 PM UTC

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 04:49 PM UTC

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 11:55 PM UTC

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 02:42 PM UTC

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 04:50 PM UTC

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.

Warning Icon 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.Close Icon

;