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.
Syncfusion Feedback

Printing a datagrid.

Thread ID:

Created:

Updated:

Platform:

Replies:

16725 Jul 22,2004 02:16 PM UTC Jul 22,2004 03:11 PM UTC Windows Forms 3
loading
Tags: GridControl
Umangi
Asked On July 22, 2004 02:16 PM UTC

I am using a DataGrid of size width=830, height =90. There are two columns of size 200,625. And the border style is thick. Now when I print the grid. Write following code if (((GridControl)panelMessages.Controls[i])!= null) { try { GridPrintDocument pd = new GridPrintDocument(((GridControl)panelMessages.Controls[i]), true); // pd.PrinterSettings = ps; pd.Print(); } catch(Exception ex) { MessageBox.Show("An error occurred attempting to print the grid - " + ex.Message); } } But only first column of grid is printed. If I reduce the left and right margin of page setting pd.DefaultPageSettings.Margins.Left=10; pd.DefaultPageSettings.Margins.Right=10; both columns get printed but right most border doesn''t get printed. This I did for testing purpose. I want margin of 100 both the sides.

Administrator [Syncfusion]
Replied On July 22, 2004 02:54 PM UTC

If you check the values of pd.DefaultPageSettings.Bounds, what do you see? If you substract the Margins, that would give you what I think would be the area available for the grid to use (There also may be some page gutter width sinvoled as well). If that is less the the grid.Bounds, then that would explain why the grid is not printing the whole area. It normally only prints full columns that will fit into the area allocated to it for printing. This may be off by a dot or so, as it also will try to draw a frame around the grid that is not part of the grid itself. If you want to try to force everything to fit on the one page, then you will have to increase the area of the print page that the grid can use, or you will have to reduce the size of the grid in some way. The latter could be done by tweaking the column widths, or you could snap a bitmap of the full grid, and then draw the bitmap scaled to the allocated page size. This last option is illustrated in the Grid\Samples\In Depth\PrintToFit sample.

Umangi
Replied On July 22, 2004 03:01 PM UTC

That''s OK if both columns are printed on different pages. I want very simple solution >If you check the values of pd.DefaultPageSettings.Bounds, what do you see? If you substract the Margins, that would give you what I think would be the area available for the grid to use (There also may be some page gutter width sinvoled as well). If that is less the the grid.Bounds, then that would explain why the grid is not printing the whole area. It normally only prints full columns that will fit into the area allocated to it for printing. This may be off by a dot or so, as it also will try to draw a frame around the grid that is not part of the grid itself. > >If you want to try to force everything to fit on the one page, then you will have to increase the area of the print page that the grid can use, or you will have to reduce the size of the grid in some way. The latter could be done by tweaking the column widths, or you could snap a bitmap of the full grid, and then draw the bitmap scaled to the allocated page size. This last option is illustrated in the Grid\Samples\In Depth\PrintToFit sample.

Administrator [Syncfusion]
Replied On July 22, 2004 03:11 PM UTC

The simplest solution I know would be to reduce the grid.Bound and the column widths until everything prints on one page with teh margins you want. The next simplest thing would be to use the PrintToFit technique by copying the code from the sample.

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

;