none
microsoft report viewer command RRS feed

  • Question

  • hello msdn,
             i had a form connected to database and also report viewer on my form after clicking the save button the report viewer are refreshing.

    Me.ReportViewer1.RefreshReport()

    and also after clicking the new button the reportViwer are clearing the content

    Me.ReportViewer1.Clear()

        i just want to view only the current report of the particular transaction after the clicked event of save button. How can i do that?

    ....or another option is to print directly the current report after the save button clicked. again how can i do that?

    kangkungkernitz1081
    • Moved by Riquel_DongModerator Wednesday, August 20, 2008 6:33 AM it is the best option to post the reportviewer control issue to here (Moved from Visual Basic Language to Visual Studio Report Controls)
    Tuesday, August 19, 2008 6:14 AM

Answers

  • I don't get the point, there are only italian words in variable names and user messages, but here are the translations:

    Public Enum enumTipoEsportazione

    Pdf = 1

    Excel = 2

    Image = 3

    End Enum


    Public
    Enum enumExportType

    Pdf = 1

    Excel = 2

    Image = 3

    End Enum


    MessageBox.Show("Impossibile connettersi alla stampante ""{0}"".", printerName)

    MessageBox.Show("Unable to connect to printer ""{0}"".", printerName)



    C.

    Thursday, August 21, 2008 12:57 PM

All replies

  • I use a couple of sub (VB code) to print a report without displaying print dialog.

    You just need to call directPrint() and you current report will be printed (I'm sorry but I have some italian word in code):


    Public Enum enumTipoEsportazione

    Pdf = 1

    Excel = 2

    Image = 3

    End Enum

    Protected Friend Sub directPrint()

    reportFileName = "tmpFile"

    Me.ExportVSReport(Me.reportFileName, enumTipoEsportazione.Image)

    Print()

    End Sub


    Protected Friend Function ExportVSReport(ByVal fileName As String, ByVal fileFormat As enumTipoEsportazione) As Boolean

    Dim bytes As Byte()

    bytes = Me.renderVSReport(fileFormat)

    If Not bytes Is Nothing Then

    Dim fs As New System.IO.FileStream(fileName, IO.FileMode.Create)

    fs.Write(bytes, 0, bytes.Length)

    fs.Close()

    End If

    End Function





    Private Sub Print()

    Dim printerName As String

    Dim oPS As New System.Drawing.Printing.PrinterSettings

    Dim printDoc As New PrintDocument()

    Try

    printerName = oPS.PrinterName

    Catch ex As System.Exception

    printerName = ""

    Finally

    oPS = Nothing

    End Try

    printDoc.PrinterSettings.PrinterName = printerName

    If Not printDoc.PrinterSettings.IsValid Then

    MessageBox.Show("Impossibile connettersi alla stampante ""{0}"".", printerName)

    Else

    AddHandler printDoc.PrintPage, AddressOf PrintPage

    printDoc.Print()

    End If

    End Sub

    Wednesday, August 20, 2008 7:50 AM
  • Code too long to stay in a single post ^_^

    Here le last fragment:

    Private Sub PrintPage(ByVal sender As Object, ByVal ev As PrintPageEventArgs)

    Dim pageImage As System.Drawing.Image

    pageImage = Image.FromFile(Me.reportFileName)

    ev.Graphics.DrawImage(pageImage, ev.PageBounds)

    ev.HasMorePages = False

    End Sub

    Wednesday, August 20, 2008 7:53 AM
  • Claudio Rossi,
            Thank you for your reply, but i dont understand your italian words. Can you translate it to english?
    Again thank you for the help.

    kangkungkernitz1081
    Thursday, August 21, 2008 2:13 AM
  • I don't get the point, there are only italian words in variable names and user messages, but here are the translations:

    Public Enum enumTipoEsportazione

    Pdf = 1

    Excel = 2

    Image = 3

    End Enum


    Public
    Enum enumExportType

    Pdf = 1

    Excel = 2

    Image = 3

    End Enum


    MessageBox.Show("Impossibile connettersi alla stampante ""{0}"".", printerName)

    MessageBox.Show("Unable to connect to printer ""{0}"".", printerName)



    C.

    Thursday, August 21, 2008 12:57 PM