I'm using the code in the KB article to print the content of a winultragrid, but the columns are extending beyond the page. I've tried calling the PerformAutoResize() function on each column but even then it causes the columns to get cutoff by the margins, and in some cases the text within the columns gets cutoff as well. What can I do to have the grid autofit to the width of the page?
If you are setting FitWidthToPages to 1 and the grid is going off the edge of the page, then clearly something is wrong.
Are you using the latest Hot Fix?
Can you duplicate this in a small sample project? If so, you should Submit an incident to Infragistics Developer Support
The same thing happens if I set the
e.PrintDocument.DefaultPageSettings.Landscape = True
I am having a similar problem. I am handling both the InitializePrint and InitializePrintPreview events, the code in both looks like:
e.PrintDocument.DefaultPageSettings.Margins.Top = e.PrintDocument.DefaultPageSettings.HardMarginY
e.PrintDocument.DefaultPageSettings.Margins.Left = e.PrintDocument.DefaultPageSettings.HardMarginX
'e.PrintDocument.DefaultPageSettings.Margins.Right = e.PrintDocument.DefaultPageSettings.HardMarginX
'e.PrintDocument.DefaultPageSettings.Margins.Bottom = e.PrintDocument.DefaultPageSettings.HardMarginY
e.DefaultLogicalPageLayoutInfo.FitWidthToPages = 1
With this code the grid scales correctly to one page wide but has a large right and bottom margin on the printed page. If I uncomment the two lines that set the right and bottom margin's, the grid flies off the side of the page.
Very frustrating :(
You could do this:
private void ultraGrid1_InitializePrintPreview(object sender, CancelablePrintPreviewEventArgs e) { e.DefaultLogicalPageLayoutInfo.FitWidthToPages = 1; }
You could do the same thing in the InitializePrint event, too.