Sometimes it is necessary to hide some toolbar buttons in ReportViewer for Silverlight.
For example, you would not like that the user can export the report to any of the formats
or print it. You can do it by setting new ViewOptions, specifying which buttons you would
like to make visible in the control. If you set the button property to true, the button
will be visible in the Silverlight Viewer.
You need to use the following code (insert this code in the
MainPage.xaml.cs):
public UserControl()
{
InitializeComponent();
reportViewer.ViewOptions = SetDefaultViewOptions(); //set default
report viewer options
}
private ViewOptions SetDefaultViewOptions()
{
ViewOptions opt = new ViewOptions();
opt.CSVExportBrowsing = false;
opt.ExcelExportBrowsing = true; //show excel export
opt.HistoryNavigatorBrowsing = false;
opt.HtmlExportBrowsing = false;
opt.MHTMLExportBrowsing = false;
opt.PageModelNavigatorBrowsing = false;
opt.PageNavigatorBrowsing = false;
opt.ParametersElementBrowsing = true;
opt.PDFExportBrowsing = true; //show pdf export
opt.PrintElementBrowsing = true; //show printing
opt.RTFExportBrowsing = false;
opt.SearchElementsBrowsing = false;
opt.TIFFExportBrowsing = false;
opt.WordExportBrowsing = true; //show word export
opt.XMLExportBrowsing = false;
opt.XPSExportBrowsing = false;
opt.ZoomElementsBrowsing = true; //show zoom control
return opt;
}
Article ID: 375, Created: August 16, 2011 at 12:17 PM, Modified: August 16, 2011 at 2:14 PM