The requested page is not available for the requested platform. You are viewing the content for Default platform.

Add Items to a Print Preview's Ribbon Toolbar

  • 2 min to read

This tutorial illustrates how to customize a Print Preview's ribbon toolbar by adding a new button to it.

Tip

See the following tutorial to learn how to add a Print Preview to a WinForms application: Create a Custom Print Preview.

Do the following to customize the ribbon toolbar of a preview form:

  1. Generate the ribbon toolbar for a DocumentViewer by clicking its smart tag and selecting the Create Ribbon Toolbar action.

    HowTo_CustomRibbonPreview_0a

  2. Click the eud-ribbon-add-button button in the ribbon's Document group and select the Add Button action.

    HowTo_CustomRibbonPreview_0b

    Change the button's caption to "Edit" and set its BarItem.Hint property to "Edit the report".

  3. Handle the button's BarItem.ItemClick event and add the required code. The following code opens the current report in End-User Report Designer:

    using DevExpress.XtraReports.UI;
    // ...
    
    private void EditBarButtonItem_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) {
        XtraReport1 report = new XtraReport1();
        ReportDesignTool designTool = new ReportDesignTool(report);
        designTool.ShowRibbonDesignerDialog();
    
        // Calling the CreateDocument method each time you show the Report Designer is required 
        // because a report cannot be edited and previewed at the same time.
        report.CreateDocument();
    }
    
    Tip

    The example above does not show how to update the document displayed in Print Preview after changing the report in Report Designer.

    See the following tutorial for a complete example: Override Commands in End-User Report Designer (Implement Custom Saving).

The following image illustrates the result:

HowTo_CustomRibbonPreview_0c