Edit Export (Save As) choices in WinForms Report Viewer

Hi,

I need to be able to make 1 report and limit what it can be saved as based on user permissions.

I dont need to add any new options (Excel and PDF are all I need) but I just want to remove one or the other from that save as drop down button.

I have read on up doing my own rendering etc, but I really hope there is just some simple way to get to that menu and gray out a choice or 2,...

Any ideas



Answer this question

Edit Export (Save As) choices in WinForms Report Viewer

  • mimminito

    I don't think you can modify the bar other than turning it off or disabling items. From my quick testing the ContextMenu seems immutable if you have it enabled. Speaking of which don't forget to hide the context menu (right click) or the users will be able to export from that menu.

    You will need to make your own bar/menu. If that looks clumsy in your UI you may want to disable the entire standard menu bar and create your own.

  • DeJohn P

    If you don't mind a little reflection...do this in your load of your report:

    Code Snippet

    foreach (RenderingExtension extension in this.reportViewer.LocalReport.ListRenderingExtensions()) {
    if (extension.Name == "Excel") { //change to "PDF" to stop acrobat export.
    ((Extension)(extension.GetType().GetField("m_serverExtension", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(extension))).Visible = false;
    }
    }

  • msec

    I don't think you can modify those choices. You could hide them and create your own menu.

  • Isuru

    Thanks for the quick reply,

    That being the case can I create a menu on the Viewer toolbar or does it have to be elsewhere, if I can add it to the standerd toolbar any idea on where to look to tie into it


  • Edit Export (Save As) choices in WinForms Report Viewer