In the code below I have Databand.DataSource.RealCount but that's not correct, and I'm not sure what property to check.
Code: Select all
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'load the report
Dim loReport = New Stimulsoft.Report.StiReport
loReport.Load("C:\TaxOverride.mrt")
'apply a filter
Dim liCompany = 941
Dim loDataband1 = DirectCast(loReport.GetComponentByName("DataBand1"), StiDataBand)
loDataband1.FilterOn = True
loDataband1.Filters.Add(New StiFilter("{Payroll_Tables.Company_Num == " & liCompany & "}"))
'figure out how many records here....
If loDataband1.DataSource.RealCount = 0 Then '<-- cant figure out what to put here, always returns 0
'don't display the viewer, just show a msgbox...
MessageBox.Show("No Records Found!")
Else
'display the report in the veiwer
Dim loViewer As New ViewerForm '<-- form containing the viewer control
loViewer.Report = loReport '<-- added property to form for report
loViewer.ShowDialog()
End If
End Sub
Code: Select all
Public Class ViewerForm
Private WithEvents mssReport As StiReport
Public WriteOnly Property Report() As StiReport
Set(ByVal value As StiReport)
mssReport = value
End Set
End Property
Private Sub ViewerForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
mssReport.Compile()
AddHandler mssReport.CompiledReport.EndRender, New EventHandler(AddressOf mssReport_Render)
With StiViewerControl1
.Dock = DockStyle.Fill
.Visible = True
.Report = mssReport
.Report.Render()
End With
End Sub
Private Sub mssReport_Render(ByVal sender As StiReport, ByVal e As EventArgs)
Dim loDataband1 = DirectCast(sender.GetComponentByName("DataBand1"), StiDataBand)
MessageBox.Show(loDataband1.DataSource.Rows.Count)
End Sub
End Class