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
After I have submitted a test project to reproduce the problem, the Infragistics support team could help me.
This problem has been fixed in the hotfix NetAdvantage 6.3.20063.1085 (CLR1.x).
No, I'm afraid that doesn't really help. I recommend creating a small sample project that demonstrates the problem and submitting it to Infragistics Developer Support. If they can duplicate the issue, they should be able to tell you what's wrong.
Submit a Support Issue
Hi Mike,
thanks for your quick response.
I created a new layout instance to fill the mandatory layout parameter in the dgBrowseResult.PrintPreview() call. I could have used the dgBrowseResult.DisplayLayout as well. But this would lead to the same NullReferenceException.
The only way I could avoid the exception was to omit the second parameter UltraGridPrintDocument (but then I miss the desired header as well). If I enter just an empty layout, the printing looks a bit simple (no 3D effects etc.), but nevertheless ok: the grid is printed with all columns. The same if I enter just the DisplayLayout: I get 3D effects and the preview prints fine.
For me, this behaviour looks like there is something wrong with the UltraGridPrintDocument, where I define the lines of my header. I needed, I can put my stuff in a test project and mail it to you.
any idea from the debug output?
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.