Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
90
Margins for InitializePrintPreview and UltraGrid Print Editable?
posted

Currently trying to print an ultragrid, it has several columns and I found the FitWidthToPage method under initialize print preview.  I'm trying to find out if there is a way to minimize the margins on the left and right on print preview and when it prints so that the page will have more room to fit the columns.  I haven't been able to find any answers yet so I figured I would try the forums.  Does anyone have any experience with this kind of situation or know if it is possible to get rid of margins for the print preview and when printing? 

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    Hi,

    You can set the margins on the PrintDocument.DefaultPageSettings. But every printer has a minimum margin on which the printer will not print. So to reduce the margins to the minimum, you could do something like this:


            private void ultraGrid1_InitializePrintPreview(object sender, CancelablePrintPreviewEventArgs e)
            {
                e.PrintDocument.DefaultPageSettings.Margins.Left = (int)Math.Ceiling(e.PrintDocument.DefaultPageSettings.HardMarginX);
                e.PrintDocument.DefaultPageSettings.Margins.Right = (int)Math.Ceiling(e.PrintDocument.DefaultPageSettings.HardMarginX);
                e.DefaultLogicalPageLayoutInfo.FitWidthToPages = 1;
            }

    I'm not sure I understand what you mean about the grid being too small. That seems to be contradictory to your first post. You want to decrease the margins to make more space but at the same time the grid is too small? That doesn't make sense. I suspect I am just misunderstanding what you mean.

Children