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
425
UltraGrid strange printing behavior
posted

Hi,

     I was trying to use the UltraPrintPreview control to print the grid.  On my main form, I have a UltraGrid and a button that will trigger the function to print the grid with a UltraPrintPreview control:

--------------code start-----------------------
UltraGridPrintDocument^ doc = gcnew UltraGridPrintDocument();
    doc->FitWidthToPages = 1;   
    doc->Page->Margins->Top = 0.5;
    doc->Page->Margins->Bottom = 0.5;
    doc->Page->Margins->Left = 0.5;
    doc->Page->Margins->Right = 0.5;
    doc->Grid = this->ultraGrid1;
    doc->Header->TextCenter =  "Title";
    doc->Header->TextRight = "Name";
    doc->Header->Height = -1;
    doc->PageBody->Margins->Top = 15;
    Infragistics::Win::Printing::UltraPrintPreviewDialog^ dialog = gcnew Infragistics::Win::Printing::UltraPrintPreviewDialog();
    dialog->Document = doc;
    dialog->ShowDialog(this);
    dialog->Document = nullptr;
    delete doc;
    delete dialog;
    doc = nullptr;
    dialog = nullptr;
--------------end of code---------------------------------

        Everything works as expected if I maximized the main form (parent window) when clicking the print button.  But if the main form was not maximized when the print button was click, the grid will not auto resize according to the paper - it seems that it will just resize according to the PrintPreviewDialog's size:
         I've also tried setting the UltraPrintPreviewDialog's window state to Maximized before calling ShowDialog(), but it doesn't have any effects on the grid resizing.  It seems like as long as the parent window is not maximized when the UltraPrintPreviewDialog was created, the grid will not resize correctly no matter what. 
        Is this a bug or am I missing something?  Thanks!