Add Items to a Print Preview's Ribbon Toolbar
- 2 minutes 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:
Generate the ribbon toolbar for a DocumentViewer by clicking its smart tag and selecting the Create Ribbon Toolbar action.
Click the button in the ribbon’s Document group and select the Add Button action.
Change the button’s caption to “Edit” and set its BarItem.Hint property to “Edit the report”.
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: