Friday, October 29, 2010

Using the MS ReportViewer control. Code. Displaying search results

Private Sub AnteRicercaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RicercaTipoAnteToolStripMenuItem.Click

If Me.txtTipo.Text = "" Or Me.txtRicerca.Text = "" Then
MsgBox("Effettuare prima la ricerca", MsgBoxStyle.Critical)
Exit Sub

End If

Report(My.Application.Info.DirectoryPath & "\AnteRicercaTipo.rdl", "Biblioteca")



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.ReportPath = filename

End Sub
Notice! To get this code working the DataSet in rdl file must have tha same name of the ReportDataSource
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.
Currently my acquaintances are limited to the type of report which I have created. Perhaps in future I will widen my acquaintances.

No comments:

Post a Comment