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

this.DrawCell+=new GridDrawCellEventHandler

In handling of the DrawCell Event, I am unable to draw outside the area specified by the clip area of the graphics objects. If I manuually expand this area, subsquent draw operations overwrite anything drawn outside the clip area. How can I handle the drawcell event, but draw outside of the clip area as well. I am setting the e.cancel property to true. Thanks, Steve

7 Replies

AD Administrator Syncfusion Team November 17, 2004 10:48 AM UTC

If you draw over a neighboring cell, how are you trying to tell the neighbor cell not to draw itself, and thus cover up what you drew. This paradox is basically why the grid generally handles drawing on a cell by cell basis, not allowing you to draw outside the cell. Exactly what are you trying to draw? Can you use Banner cell techniques to do it? (Grid\Samples\Quick Start\BannerCells) Or, you could derive the grid, override OnPaint. In your override, call the base class to do the stardard drawing of the cells. Then if your special cell is visible, do your special drawing at this point. This way, the other cells painting will not step on what you try to draw. Or maybe coveredcells? This way all the drawing is in one cell.

ST Steve November 17, 2004 11:09 AM UTC

I am trying to draw a border around a cell that extends into a cell below the cell with the border. I thought of the onPaint as well, but I was trying to prevent from checking all viewable cells to determine if it has this special border ther overflows into cell below it. I guess I could handle the cell that that is being overflown in the draw event, but it may be easier just to do the work in the onPaint event although I''m a little concerned about performance. Any other ideas? Thanks.

AD Administrator Syncfusion Team November 17, 2004 11:36 AM UTC

I think OnPaint might be you best option. One thing you could try is to still handle DrawCell and there set a flag (or store some kind of row/col key in a hashtable/arraylist) for the cells that need the special border. Then your OnPaint code could just check this hashtable and draw the borders fro the cells in it (and then clear the hashtable). This way, your OnPaint code would not have to do too much work to know exactly what cells it must draw.

ST Steve November 17, 2004 04:25 PM UTC

What is the easiest way to get the row/col range specified by the clipRectangle in the onPaint event? Currently I''m using the following code to get the top,bottom,left and right of the cell range. this.gridControl1.ViewLayout.RectangleToClientRowCol(e.ClipRectangle,out top,out left,out bottom, out right,GridCellSizeKind.ActualSize); top += this.gridControl1.ViewLayout.VisibleCellsRange.Top; bottom += .gridControl1.ViewLayout.VisibleCellsRange.Top; right += this.gridControl1.ViewLayout.VisibleCellsRange.Left; left += this.gridControl1.ViewLayout.VisibleCellsRange.Left; Seems like they would be a call to get a GridRangeInfo object specifeid by the rectangle in the onPaint event? Thanks, Steve

AD Administrator Syncfusion Team November 17, 2004 05:39 PM UTC

Will grid.RectangleToRangeInfo give you what you want?

ST Steve November 17, 2004 06:11 PM UTC

Thanks Clay. One more question.... Upon scrolling the grid, a small region is invalidated thru the paint command. If my special cell is IN this region, but some of my special border that I want to draw is outside the region the grid does not paint anything outside the region. How can I force scroll to refresh a slightly larger region upon scrolling or allow drawing outside the region specified by the graphics object in the onPaint command. Thanks, Steve >Will grid.RectangleToRangeInfo give you what you want?

AD Administrator Syncfusion Team November 17, 2004 06:18 PM UTC

You can try setting this.gridControl1.DisableScrollWindow = True; but this will affect scrolling performance as the whole grid is redrawn. The other option is to somehow call grid.InvalidateRect yourself with the piece you want redrawn. (If you do this from within OnPaint, you are likely to need a flag to prevent recursive calls.

Live Chat Icon For mobile
Up arrow icon