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
close icon

How to get DrawGrid() to draw the middle of a grid?

I'm using the grid's DrawGrid() method to draw the grid to a graphics context, but I don't see any way to draw, say, the middle portion of the grid. The grid always draws from the first row and column, then as far as it can to the left and down as determined by the bounds parameter if the DrawGrid() method. Is there any way to offset upper-left coordinate of the drawn grid to any coordinate I want?

4 Replies

AD Administrator Syncfusion Team April 26, 2004 08:56 PM UTC

You can try hiding the rows/columns you do not want grid.DrawGrid to draw. (You can do this dynamically in QueryRowCount/QueryColCount, returning e.Size = 0 for the rows/cols you do not want to see.)


DO Don April 27, 2004 10:02 AM UTC

> You can try hiding the rows/columns you do not > want grid.DrawGrid to draw. (You can do this > dynamically in QueryRowCount/QueryColCount, > returning e.Size = 0 for the rows/cols you do > not want to see.) That's going to be really messy with what I've already got going on with the grid I'm trying to print. There's no other way to draw a portion of the grid that's doesn't have its upper-left corner at 0,0 ?


AD Administrator Syncfusion Team April 27, 2004 05:37 PM UTC

One other alternative would be to set the GridBounds or PrintBounds such that you can then draw only the region you need by clipping the graphics context. Suppose the grid has width = 200 and height = 100 and you want to draw the cells inside the grid that start at 50,50 and end at 150,150 at the form postion 10, 10. You could use the following logic: Region r = graphics.Clip; // Save clip region grid.GridBounds (or PrintBounds) = new Rectangle(10-50, 10-50, 200, 100) graphics.IntersectClip(new Rectangle(10, 10, 150-50, 150-50)); // draw the grid here. It will draw the rectangle from (-40, -40) to (160, 60) but will clip the output to (10, 10) to (110, 110). grpahics.Clip = r; // Reset clip region Stefan


S_ Stephane _ December 3, 2008 07:10 PM UTC

Do you guys have an other way of doing this or is it still the way to do it?


Loader.
Live Chat Icon For mobile
Up arrow icon