A fast, cross-platform report and document viewer for .NET reporting, ComponentOne FlexViewer offers a complete control toolkit that can be used to preview many different document types, including a C1Report, C1FlexReport, SSRS, and PDF documents.

This control offers a Ribbon that consists of standard Ribbon items. At times, you may need to hide these standard buttons or add a custom button in the Ribbon.

How to hide or show standard buttons in ComponentOne FlexViewer

There are two ways to change the visibility of standard buttons:

I. When designing, use RibbonElements collection editor.

  • Go to the Properties window.

  • Expand RibbonElements property.

  • Change the Visible property of the desired ButtonActionElement.

flexviewer-winforms-customization

II. At run time, you can use any of the following methods:

  • Get an object of ButtonActionElement class from the RibbonElements:
//Hide Refresh button from the Ribbon
ButtonActionElement _btnRefresh= _flxViewer.RibbonElements.Refresh;
_btnRefresh.Visible = false;
  • Get an object of RibbonItem class from the RibbonGroup:
//Hide Print button from the Ribbon
_flxViewer.RibbonGroups.Tools.RibbonGroup.Items[0].Visible = false;

Add custom button(s):

You can add a RibbonItem in the RibbonGroup programmatically.

// Add a custom Print button and hide the standard one
RibbonButton _btnCustomPrint = new RibbonButton();
 //Get standard Print button
RibbonItem _btnPrint = _flxViewer.RibbonGroups.Tools.RibbonGroup.Items[0];
_btnCustomPrint.LargeImage = _btnPrint.LargeImage;
_btnCustomPrint.SmallImage = _btnPrint.SmallImage;
_btnCustomPrint.ToolTip = "Custom button to print current report";
_btnCustomPrint.TextImageRelation = _btnPrint.TextImageRelation;
_btnCustomPrint.Text = "Custom print";
//Add event handler
_btnCustomPrint.Click += _btnCustomPrint_Click;
_flxViewer.RibbonGroups.Tools.RibbonGroup.Items.Insert(1, _btnCustomPrint);

Available in: Desktop: WinForms, WPF, UWP Web: ASP.NET MVC

Try the fastest way to build high-performing, feature-complete applications. Download a ComponentOne FlexViewer free trial today.