Skip to main content

Add Button to Print Preview Standard Toolbar

  • 2 minutes to read

This help topic demonstrates how to add a new command button to Print Preview standard toolbar.


Create a WinForms project, add the DocumentViewer control to a form, add a new report to the project. Review the forllowing topic for more information: Create a Report in Visual Studio.

Generate the DocumentViewer standard toolbar. To do this, click the DocumentViewer smart tag and select Create Standard Toolbar.

Add Standard Toolbar to WinForms Preview

Add a Custom Button

  1. Click the [Add] button in the Print Bar Manager menu and add a new button to the menu.

    Add Button to Standard Toolbar in WinForms Preview

  2. Change the button caption to Edit and set the BarItem.Hint property to Edit the report:

    Specify Button Hint in the Standard Toolbar in WinForms Preview

  3. Move the **Edit ** button from the menu to the toolbar:

    Move Button From Menu to Toolbar

  4. Handle the button’s BarItem.ItemClick event, and add the following code snippet that opens the current report in End-User Report Designer:

    using DevExpress.XtraReports.UI;
    // ...
    private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) {
        var report = (XtraReport)Activator.CreateInstance((Type)this.documentViewer1.DocumentSource);
        ReportDesignTool designTool = new ReportDesignTool(report);


This code snippet does not update the document displayed in Print Preview after the report in the Report Designer is changed. Review the following help topic for more information on Print Preview commands: Print Preview Commands - Execute, Override, Hide.

The following image shows the application after a user clicks a custom button:

Custom Button in a Print Preview Standard Toolbar - Result