In the first place download the ReportViewer control from here or from the Microsoft site: download this file from link “Add in” in the bottom of the page. The file which therefore you will download has the SQLServer2005_ReportAddin name but you may rename it as es “ReportViewer Control” in order to identify it.
Warning: to install Reportviewer control you have to install before Visual Web Developer of the swite Visual Studio Express 2005. This is a disvantage of the Reportviwer control actually.
After executing the installation you will find in VB.net one control Reportviewer for Windows Form and one for Web form. But attention: in order to make to appear the control in the toolbox you must add in the project the Microsoft.Reportviewer.Common reference.
Important: solved the problem of the print button inactive in the reportvierwer control
I have noticed that when I open the preview window of the reportviewer control and am printing a report, the print button is inactive. This is a bug of the reportviewer control. However the problem can easily be solved by double clicking the print button.
And now an example of code which allows you to visualize any lines of your choice of any table, after a search in any datatable (dataset1 is a not typified dataset). This code is an elaboration of a job of Omar Damiani exposed in this page :
Private Sub AnteRicercaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RicercaTipoAnteToolStripMenuItem.Click
If Me.TextBox1.Text = "" Or Me.TextBox2.Text = "" Then
MsgBox("Perform before the search", MsgBoxStyle.Critical)
Exit Sub
End If
Report(My.Application.Info.DirectoryPath & "\AnteRicercaTipo.rdl", "YourTable")
RepTipo.ReportViewer1.Refresh()
RepTipo.Show()
End Sub
Private Sub Report(ByVal filename As String, ByVal table As String)
Dim RepDS As New ReportDataSource
Dim dv As New System.Data.DataView
dv = DataSet1.Tables(table).DefaultView
RepDS.Name = "DataSource1"
RepDS.Value = dv
RepTipo.ReportViewer1.LocalReport.DataSources.Clear()
RepTipo.ReportViewer1.LocalReport.DataSources.Add(RepDS)
RepTipo.ReportViewer1.LocalReport.ReportPath = filename
End Sub
Trying in google you will be able to find much documentation on how creating a report. In particular I council this link for customizining layout of report and the this link for a practice with ReportViewer.
If you have of the problems with these articles you can contact me obviously.
N.B.
Actually my acquaintances are limited to the type of report which I have created. Perhaps in future I will widen my acquaintances.
Using the ReportViewer control. Code. Displaying the result of a search.
Posted by Giovanni G Edit
Subscribe to:
Post Comments (Atom)

0 comments:
Post a Comment