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