〔winform〕
VB.NET
Private Sub ReportViewer1_RenderingBegin(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ReportViewer1.RenderingBegin
Dim info As FieldInfo
For Each extension In Me.ReportViewer1.LocalReport.ListRenderingExtensions()
If extension.Name = "PDF" Then
info = extension.GetType().GetField("m_isVisible", BindingFlags.Instance Or BindingFlags.NonPublic)
info.SetValue(extension, False)
End If
Next
End Sub
C#
//string exportOption = "Excel";
//string exportOption = "Word";
string exportOption = "PDF";
RenderingExtension extension = reportViewer1.LocalReport.ListRenderingExtensions().ToList().Find(x => x.Name.Equals(exportOption, StringComparison.CurrentCultureIgnoreCase));
if (extension != null)
{
System.Reflection.FieldInfo fieldInfo = extension.GetType().GetField("m_isVisible", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
fieldInfo.SetValue(extension, false);
}
參考:
禁止ReportViewer工具栏上的导出按钮?
reportviewer禁止导出Excel按钮
ReportViewer - Hide PDF Export
ReportViewer 2010:how to hide pdf in export option in reportviewer
Hide (Disable) specific export option in ReportViewer from Export button
Hide (Disable) specific export option (Word / Excel / PDF) from Export button
沒有留言:
張貼留言