Demand: A similar RadRichTextEditor printing method that requires a print event

4 posts, 0 answers
  1. zhijun
    zhijun avatar
    9 posts
    Member since:
    Jun 2016

    Posted 31 Mar 2018 Link to this post

    RadRichTextEditor prints the code as follows:

                         RadPrintDocument document = new RadPrintDocument();
                         document.PrintPage += (s, e) => { action?.Invoke(); };
                         richTextEditor.PrintPreview(document);

    Does RadSpreadsheet have such a Print/PrintPreview method?

  2. Hristo
    Admin
    Hristo avatar
    1508 posts

    Posted 02 Apr 2018 Link to this post

    Hello,

    RadSpreadSheet have both the Print and PrintPreview methods. You can check the following documentation article: https://docs.telerik.com/devtools/winforms/spreadsheet/features/printing.

    Let me know if have other questions.

    Regards,
    Hristo
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. zhijun
    zhijun avatar
    9 posts
    Member since:
    Jun 2016

    Posted 03 Apr 2018 in reply to Hristo Link to this post

    I want the Print/PrintPreview method to pass a RadPrintDocument object that records whether the user printed the document.
  4. Hristo
    Admin
    Hristo avatar
    1508 posts

    Posted 04 Apr 2018 Link to this post

    Hello,

    Thank you for writing back.

    Printing in the spread control is handled slightly different compared to how printing is implemented our other controls. Actually, RadSpreadSheet is also working with RadPrintDocument objects, however, these objects are created dynamically and they are not exposed publically. I have logged a feature request in our feedback portal, here: ADD. RadSpreadsheet - expose an API notifying that a print or print preview job is underway. I have also updated your Telerik points. We will do our best to fix the issue in the R2 2018 release.

    For the time being, you can use the workaround below handling the PrintPreview method: 
    private void button1_Click(object sender, EventArgs e)
    {
        RadPrintDocument printDocument = new RadPrintDocument();
        IPrintable printManager = typeof(RadSpreadsheetElement).GetProperty("PrintManager", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(this.radSpreadsheet1.SpreadsheetElement) as IPrintable;
        printDocument.AssociatedObject = printManager;
     
        printDocument.BeginPrint += PrintDocument_BeginPrint;
        printDocument.PrintPage += PrintDocument_PrintPage;
        printDocument.EndPrint += PrintDocument_EndPrint;
        printDocument.QueryPageSettings += PrintDocument_QueryPageSettings;
     
        SpreadsheetPrintPreviewDialog printPreviewDialog = new SpreadsheetPrintPreviewDialog(printDocument);
        printPreviewDialog.ThemeName = this.radSpreadsheet1.ThemeName;
        printPreviewDialog.ShowDialog();
    }
     
    private void PrintDocument_QueryPageSettings(object sender, System.Drawing.Printing.QueryPageSettingsEventArgs e)
    {
         
    }
     
    private void PrintDocument_EndPrint(object sender, System.Drawing.Printing.PrintEventArgs e)
    {
         
    }
     
    private void PrintDocument_BeginPrint(object sender, System.Drawing.Printing.PrintEventArgs e)
    {
         
    }
     
    private void PrintDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
    {
    }

    I hope this helps. Let me know if you need further assistance.

    Regards,
    Hristo
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top