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
65
Print from UltraWinGrid.PrintPreview throws NullReferenceException
posted

I get a NullReferenceException from the UltraWinGrid, when clicking the Print button in the PrintPreview dialog. The preview output looks fine. My Code is:

UltraGridLayout ugLayout = new UltraGridLayout();
ugLayout.Reset();

UltraGridPrintDocument ugPrintDoc = new UltraGridPrintDocument();
ugPrintDoc.DocumentName = filterName;
ugPrintDoc.Grid = dgBrowseResult;

// Header with:
// <browsing ts>  <filterName>  <printing ts>

HeaderFooterPageSection ugpdHeader = ugPrintDoc.Header;

ugpdHeader.TextLeft = "TimestampBrowsing " + filterAppliedAt.ToString();

ugpdHeader.TextRight = "TimestampPrinting " + DateTime.Now.ToString();

ugpdHeader.TextCenter = filterName + "\n" + criteria + "\n" + printingAllRows;

dgBrowseResult.PrintPreview(ugLayout, ugPrintDoc);

The error log is:

2008-01-08 10:46:34,734 [2700] ERROR DEV-LOG PrintResultList - System.NullReferenceException: Object reference not set to an instance of an object.
   at Infragistics.Win.UltraWinGrid.PrintManager.CalculateFirstRows()
   at Infragistics.Win.UltraWinGrid.PrintManager.CalculatePageDimensions()
   at Infragistics.Win.UltraWinGrid.PrintManager.BeginPrint(Object sender, PrintEventArgs e)
   at System.Drawing.Printing.PrintDocument.OnBeginPrint(PrintEventArgs e)
   at Infragistics.Win.Printing.UltraPrintDocument.OnBeginPrint(PrintEventArgs e)
   at Infragistics.Win.UltraWinGrid.UltraGridPrintDocument.OnBeginPrint(PrintEventArgs e)

The error does not occur if I omit the PrintDocument parameter: dgBrowseResult.PrintPreview(ugLayout)

But I need to print the header as well!

Thanks in advance for any hint.

Holger 

using: VS 2003, C#, .Net 1.1, Infragistics NetAdvantage 2006 Volume 3 CLR 1.x

 

 

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

     Hi Holger,

        I'm not sure I understand what you are trying to do here. Why are you creating a new, completely empty layout? The operation probably should not be raising an exception, tha is probably a bug. But even if this worked, you would end up printing nothing, because your layout will have no bands or columns.

        You mention something about the header, but that has nothing to do with the layout. 

         

Children