Skip to main content
A newer version of this page is available. .

Add Items to a Print Preview's Standard Toolbar

  • 2 minutes to read

This tutorial illustrates how to customize a Print Preview’s standard 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 standard toolbar of a preview form:

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

    document-preview-windows-forms-select-toolbar

  2. Click the [Add] button displayed in the Print Bar Manager‘s menu and add a new button to the menu.

    HowTo - CustomPreviewForm_4.png

    Change the button’s caption to “Edit” and set its BarItem.Hint property to “Edit the report”.

  3. You can move this button from the Print Preview’s menu to its toolbar, next to the other buttons.

    HowTo - CustomPreviewForm_6.png

  4. 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.ShowDesignerDialog();
    
        // 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 - CustomPreviewForm_7.png