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

Render To Graphic instead of to grid

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?

5 Replies

AD Administrator Syncfusion Team 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?


AD Administrator Syncfusion Team 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 ?


AD Administrator Syncfusion Team 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 ?


AD Administrator Syncfusion Team 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...


AD Administrator Syncfusion Team 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... >

Loader.
Live Chat Icon For mobile
Up arrow icon