ReportViewer - Hide PDF Export

前端 未结 18 1624
暖寄归人
暖寄归人 2020-12-13 10:40

I make use of a ReportView component in a VB.Net 2005 app. How can I disable the PDF export functionality, only keeping the MS Excel format?

18条回答
  •  轮回少年
    2020-12-13 10:54

    If it helps... the code to hide the excel item em VB.Net (.Net 3.5)

    Private Sub CustomizeRV(ByVal ctrl As ReportViewer)
    
        For Each c As Control In ctrl.Controls
    
            If c.GetType.ToString = "Microsoft.Reporting.WebForms.ToolbarControl" Then
    
                For Each ct In c.Controls
    
                    If ct.GetType.ToString = "Microsoft.Reporting.WebForms.ExportGroup" Then
    
                        Dim cbo As DropDownList = CType(ct.controls(0), DropDownList)
    
                        AddHandler cbo.PreRender, AddressOf cboExportReportViewer_PreRender
    
                    End If
    
                Next
    
            End If
    
        Next
    
    End Sub
    
    Protected Sub cboExportReportViewer_PreRender(ByVal sender As Object, ByVal e As System.EventArgs)
    
        Dim cbo = CType(sender, DropDownList)
    
        For i As Integer = 0 To cbo.Items.Count - 1
    
            If cbo.Items(i).Text.ToLower = "excel" Then
                cbo.Items.Remove(cbo.Items(i))
                Exit Sub
            End If
    
        Next
    
    End Sub
    

    ... and put a call to CustomizeRV(ReportViewer1) in the page_load event

提交回复
热议问题