none
Report Viewer RRS feed

  • Question

  • Hello to everyone

    I am new to report viewer. I am developing a application in vb.net 2010. One of my friend suggested me to use Report viewer for printing. [Unfortunately he also don't know much]. I have a form of salary data, with 3 buttons, save, print and exit, after saving the data, i wanted to print current form in report viewer.

    Definitely, this will be simple question for most of the people. Seriously, i am struggling from a week. 

    i have crated report viewer and data-set. 

    Any suggestion will save my further time.

    Thanks in advance.

    Regards

    Kiran

    Sunday, August 19, 2012 9:28 AM

All replies

  • Kiran,

    You need to further refine your question. You have several choices :

    1) From a Windows form, you simply want to print the form. You don't need to use Report Viewer for this. Here is an example :

        Private Sub PrintButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintButton.Click
            Using p As New Microsoft.VisualBasic.PowerPacks.Printing.PrintForm
                p.PrintAction = Printing.PrintAction.PrintToPreview
                p.PrinterSettings.DefaultPageSettings.Landscape = True
                p.PrinterSettings.DefaultPageSettings.Margins.Left = 25
                p.PrinterSettings.DefaultPageSettings.Margins.Right = 25
                p.Print(Me, Microsoft.VisualBasic.PowerPacks.Printing.PrintForm.PrintOption.Scrollable)
            End Using
        End Sub
    

    2) You want to display and/or print a report. This is different from a from. A report typically has several columns, a line of total/subtotals, etc. For this, you need Report Viewer. You can first display the report in a form, then the user has the possibility to print or export the report in Excel/Word/PDF. You will need to create the report (as an .rdlc file), then create a form containing a ReportViewer. At runtime, you have to specify the name of the report, load the datasource and display the form :

    f.ReportViewer1.LocalReport.ReportEmbeddedResource = nameOfReport
    
    f.ReportViewer1.LocalReport.DataSources.Clear
    f.ReportViewer1.LocalReport.DataSources.Add(theDataSource)
    
    f.ReportViewer1.SetDisplayMode(DisplayMode.PrintLayout)
    f.ShowDialog()
    

    Tuesday, August 21, 2012 1:09 PM