虽然我意识到我可以展示的形式屏幕,并把它隐藏,以及许多其他形式的它予以解决了魔法,我宁愿坚持禅道路并获得这样做的权利。我有一个。当地的报告(所没有的服务器),我想给用户选择的任查看或打印(换句话说,我不想强迫他们看到打印)。不幸的是,含控制抱怨关于其"国家",当我试着打印它作为一个组件我正在创造明确,在我的代码(内部使用()块的课程),或者如果我尝试实例我的观众形式,只是打印而没有表示它。

有没有手段来这样做,将坐好跟我,或者我应该只是展示它关掉屏幕上,并将与我的生活?

有帮助吗?

解决方案

我有一个样品,这张贴在我的博客在这里: http://blogs.msdn.com/brianhartman/archive/2009/02/27/manually-printing-a-report.aspx

该LocalReport对象可以是实例独立的逻辑控制和使用直接在样品代码贴到那个博客。或者你可以通过在逻辑.LocalReport甚至如果你不首先显示报告的用户界面。

其他提示

看看这个,看看它是否有助于...http://scruffylookingcatherder.com/archive/2007/12/07/printing-reporting-services-2005-reports.aspx

解释一下:这是使用固态继电器网的服务呈现的报告的一个电磁场的影像然后发送的图像机和打印机。

Private Sub btnReceipt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReceipt.Click


    My.Forms.FormA5.ReportViewer.LocalReport.DataSources.Clear()
    Dim cmd = New SqlClient.SqlCommand("Select * from V_Sale where InvoiceNo=" & Me.txtInvoice.Text, cn)
    Dim dr = cmd.ExecuteReader()
    Dim dt As New DataTable
    dt.Load(dr)
    dr.Close()
    Dim rpt As New ReportViewer
    rpt.LocalReport.DataSources.Clear()
    rpt.LocalReport.DataSources.Add(New ReportDataSource("posds_receipt", dt))
    rpt.LocalReport.ReportEmbeddedResource = "POSsystem.receipt.rdlc"
    rpt.SetDisplayMode(DisplayMode.PrintLayout)
    rpt.ZoomMode = ZoomMode.FullPage

    Dim printDialog1 As PrintDialog = New PrintDialog
    printDialog1.Document = PrintDocument1
    Dim result As DialogResult = printDialog1.ShowDialog
    If (result = DialogResult.OK) Then
        PrintDocument1.Print()
    End If

End Sub
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top