This is a migrated thread and some comments may be shown as answers.

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

3 Answers 14 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
zhijun
Top achievements
Rank 1
zhijun asked on 31 Mar 2018, 12:48 PM

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?

3 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 02 Apr 2018, 03:59 PM
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.
0
zhijun
Top achievements
Rank 1
answered on 03 Apr 2018, 01:04 PM
I want the Print/PrintPreview method to pass a RadPrintDocument object that records whether the user printed the document.
0
Hristo
Telerik team
answered on 04 Apr 2018, 11:56 AM
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.
Tags
Spreadsheet
Asked by
zhijun
Top achievements
Rank 1
Answers by
Hristo
Telerik team
zhijun
Top achievements
Rank 1
Share this question
or