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.

this.DrawCell+=new GridDrawCellEventHandler

Thread ID:





21669 Nov 17,2004 05:37 AM Nov 17,2004 01:18 PM Windows Forms 7
Tags: GridControl
Asked On November 17, 2004 05:37 AM

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

Administrator [Syncfusion]
Replied On November 17, 2004 05:48 AM

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.

Replied On November 17, 2004 06:09 AM

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.

Administrator [Syncfusion]
Replied On November 17, 2004 06:36 AM

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.

Replied On November 17, 2004 11:25 AM

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

Administrator [Syncfusion]
Replied On November 17, 2004 12:39 PM

Will grid.RectangleToRangeInfo give you what you want?

Replied On November 17, 2004 01:11 PM

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?

Administrator [Syncfusion]
Replied On November 17, 2004 01:18 PM

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.


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.