I know I could handle the print event, and cancel the print, with a nice message to user saying print isn't allowed. But I would prefer to just get rid of the print button on the report viewer altogether.
6 Answers, 1 is accepted
Can you specify which viewer you refer to? The Web Report Viewer and Windows Forms Report Viewer both have ShowPrintButton property, which when set to false, would hide the Print Button.
The Silverlight Report Viewer and WPF Report Viewer on the other hand are templates which can be edited to remove the Print button. For more information refer to Creating Style in Expression Blend help article.
Greetings,
Steve
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
I followed the link regarding editing the style in Blend. All I have done is in Blend, I chose the option to Edit a Copy of the style. I have not made any changes yet; I simply did this, built my project, and tried to run it. During runtime, I now get this error:
{System.ArgumentNullException: Value cannot be null.
Parameter name: defaultStyleKey
at Telerik.Windows.Controls.Theme.GetResourceValue(Type defaultStyleKey, Theme theme, Theme controlTheme)
at Telerik.Windows.Controls.Theme.GetThemeStyle(Theme oldTheme, Type defaultStyleKey)
at Telerik.Windows.Controls.StyleManager.OnBasedOnChanged(DependencyObject d, DependencyPropertyChangedEventArgs args)
at Telerik.Windows.PropertyMetadata.<>c__DisplayClass1.<Create>b__0(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
at Telerik.Windows.Controls.StyleManager.SetBasedOn(DependencyObject obj, Theme value)}
Since I have not changed anything, I am not sure why I am getting that error. I see in the style markup where the print button is being added...but I first need to get this code to run before manipulating with the style markup.
Here is what my ReportViewer xaml looks like:
<
telerik:ReportViewer
HorizontalAlignment
=
"Center"
Name
=
"reportViewer1"
Style
=
"{StaticResource ReportViewerStyle}"
VerticalAlignment
=
"Top"
Height
=
"auto"
Width
=
"auto"
Margin
=
"0,20,0,0"
ReportServiceUri
=
"{Binding ReportUri}"
Report
=
"{Binding ReportType}"
/>
Thanks for your help!
Stacey
So the line of code that is blowing up in the generated style is this, on the StyleManager part:
<Style x:Key="ProgressBarStyle" telerik1:StyleManager.BasedOn="{StaticResource Theme}" TargetType="telerik1:RadProgressBar">
I do have a Theme style tag that was declared above this:
<telerik1:Office_BlackTheme x:Key="Theme"/>
I do not have a reference to the Office_Black theme, but I do to the Vista_Theme; so I changed this key to point to the Vista theme. This still blew up on the same line for me.
So I changed this back to the original value of Office_BlackTheme, and I added a reference to this theme's dll. This blew up on me on the same line too.
So then I tried just removing the telerik1:StyleManager.BasedOn="{StaticResource Theme}" portion of the ProgressBarStyle, and this worked.
I am not sure why...I am okay with not having this specified to the "Theme", but I am curious why this was erroring on me.
Thanks for your assistance!
Stacey
It seems this is a problem of how Blend generates the copy of the original template. We would look into that and see whether we could do anything to prevent this problem. Removing this binding would not cause any problems, so you can use it like this.
Kind regards,
Steve
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>