When use the UltraPrintPreviewControl to preview the content of the UltraWinGrid, close the form where the UltraPrintPreviewControl is in, System.NullReferenceException is thrown.
Exception trace is : 場所 Infragistics.Win.UltraWinGrid.RowColRegionIntersectionUIElement.OnAfterDraw(UIElementDrawParams& defaultDrawParams) 場所 Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) 場所 Infragistics.Win.UIElement.DrawChildElements(UIElementDrawParams& drawParams) 場所 Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) 場所 Infragistics.Win.UIElement.DrawChildElements(UIElementDrawParams& drawParams) 場所 Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) 場所 Infragistics.Win.UIElement.DrawHelper(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Boolean clipText, Boolean forceDrawAsFocused, Boolean preventAlphaBlendGraphics) 場所 Infragistics.Win.UIElement.Print(Graphics graphics, Boolean clipText) 場所 Infragistics.Win.UltraWinGrid.PrintManager.PrintPage(Object sender, PrintPageEventArgs ev) 場所 System.Drawing.Printing.PrintPageEventHandler.Invoke(Object sender, PrintPageEventArgs e) 場所 System.Drawing.Printing.PrintDocument.OnPrintPage(PrintPageEventArgs e) 場所 Infragistics.Win.Printing.UltraPrintDocument.OnPrintPageBody(PrintPageEventArgs e) 場所 Infragistics.Win.Printing.UltraPrintDocument.OnPrintPage(PrintPageEventArgs e) 場所 System.Drawing.Printing.PrintDocument._OnPrintPage(PrintPageEventArgs e) 場所 System.Drawing.Printing.PrintController.PrintLoop(PrintDocument document) 場所 System.Drawing.Printing.PrintController.Print(PrintDocument document) 場所 System.Drawing.Printing.PrintDocument.Print() 場所 Infragistics.Win.Printing.UltraPrintPreviewControl.GeneratePreviewHelper(Boolean synchronous) 場所 Infragistics.Win.Printing.UltraPrintPreviewControl.OnApplicationIdle(Object sender, EventArgs e) 場所 System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32 grfidlef) 場所 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) 場所 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) 場所 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) 場所 System.Windows.Forms.Application.Run(Form mainForm)
source:
UltraGridPrintDocument ugrpd; UltraPrintPreviewControl ultraPrintPreviewControl; ....... ultraPrintPreviewControl.Document = ugrpd; ultraPrintPreviewControl.InvalidatePreview(); ugrpd.PageHeaderPrinting += new HeaderFooterPrintingEventHandler(ugrpd_PageHeaderPrinting); // Preview status display private void ugrpd_PageHeaderPrinting(object sender, HeaderFooterPrintingEventArgs e) { ......... if (UserCloseForm()) // user can close the form. { { this.Dispose(); // form close. } } } How can I stop the print preview ,when in preview status display.
I'm 'fraid i didn't say the problem clear.I mean when the preview process bar was being shown, click the button of "CLOSE WINDOW" ,System.NullReferenceException is thrown. Sorry can you try again.
Still works just fine for me. No exception.