Completed
Last Updated: 27 Apr 2023 06:55 by ADMIN
Release R2 2023 (LIB 2023.1.427)
Gustavo
Created on: 05 Apr 2023 08:33
Category: RichTextEditor
Type: Bug Report
1
RadRichTextEditor: System.NullReferenceException when printing after pasting into the document

Copy some content and paste it in the editor. The PasteOptions dialog remains opened and if the user clicks the PrintPreview button an error occurs:

Stack trace:

************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
   at Telerik.WinControls.RichTextEditor.UI.PasteOptionsPopup.OnRichTextBoxLayoutUpdated(Object sender, EventArgs e)
   at Telerik.WinControls.Layouts.ContextLayoutManager.fireLayoutUpdateEvent()
   at Telerik.WinControls.Layouts.ContextLayoutManager.UpdateLayout()
   at Telerik.WinForms.Documents.UI.DocumentPrintPresenter.Telerik.WinForms.RichTextEditor.IDocumentEditorPresenter.UpdateLayout()
   at Telerik.WinForms.RichTextEditor.RadRichTextBox.<>c__DisplayClass653_0.<UpdateEditorLayout>b__0()
   at Telerik.WinForms.RichTextEditor.RadRichTextBox.UpdateEditorLayout(Boolean focusCarret, Boolean updateCaretSize, Boolean async)
   at Telerik.WinForms.RichTextEditor.RadRichTextBox.set_ActiveEditorPresenter(IDocumentEditorPresenter value)
   at Telerik.WinForms.RichTextEditor.RadRichTextBox.Telerik.WinControls.UI.IPrintable.BeginPrint(RadPrintDocument sender, PrintEventArgs args)
   at Telerik.WinControls.UI.RadPrintDocument.OnBeginPrint(PrintEventArgs e)
   at System.Drawing.Printing.PrintDocument._OnBeginPrint(PrintEventArgs e)
   at System.Drawing.Printing.PrintController.Print(PrintDocument document)
   at System.Drawing.Printing.PrintDocument.Print()
   at System.Windows.Forms.PrintPreviewControl.ComputePreview()
   at System.Windows.Forms.PrintPreviewControl.CalculatePageInfo()
   at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
   at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
   at System.Windows.Forms.Control.InvokeMarshaledCallbacks()

1 comment
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 05 Apr 2023 09:38

Hello, Gustavo,

Thank you for reporting this unexpected behavior. It seems that after pasting the PasteOptions dialog remains opened. Then, when the user hits the PrintPreview dialog, the error occurs.

Currently, the possible solution that I can suggest is to hide the MiniToolBar with the paste options before printing: 

        public RadForm1()
        {
            InitializeComponent(); 
            this.richTextEditorRibbonBar1.BackstageControl.BackstageViewOpening+=BackstageControl_BackstageViewOpening;
        }       

        private void BackstageControl_BackstageViewOpening(object sender, CancelEventArgs e)
        {
            ((Telerik.WinControls.RichTextEditor.UI.PasteOptionsPopup)this.radRichTextEditor1.RichTextBoxElement.PasteOptionsPopup).Hide(this.radRichTextEditor1.RichTextBoxElement); 
        }

Please excuse us for the inconvenience caused.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.