Disable Report Viewer Print Button

7 posts, 2 answers
  1. Stacey Haslag
    Stacey Haslag avatar
    30 posts
    Member since:
    Oct 2009

    Posted 12 Aug 2011 Link to this post

    Is there a way I can remove or disable the print button from the Report Viewer?

    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.
  2. Dav
    Dav avatar
    3 posts
    Member since:
    Aug 2011

    Posted 12 Aug 2011 Link to this post

    Set property ShowPrintButton = False
  3. Answer
    Steve
    Admin
    Steve avatar
    10941 posts

    Posted 12 Aug 2011 Link to this post

    Hi Stacey,

    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 >>

  4. Stacey Haslag
    Stacey Haslag avatar
    30 posts
    Member since:
    Oct 2009

    Posted 12 Aug 2011 Link to this post

    I am using the Silverlight Report Viewer. Sorry, I should have clarified that. Therefore, I don't have a "ShowPrintButton" property available.

    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
  5. Stacey Haslag
    Stacey Haslag avatar
    30 posts
    Member since:
    Oct 2009

    Posted 12 Aug 2011 Link to this post

    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


  6. Answer
    Steve
    Admin
    Steve avatar
    10941 posts

    Posted 15 Aug 2011 Link to this post

    Hi 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 >>

  7. Ahaiziah
    Ahaiziah avatar
    1 posts
    Member since:
    Mar 2019

    Posted 08 Mar in reply to Stacey Haslag Link to this post

    how do you do this?
Back to Top