filtered databand record count

Stimulsoft Reports.NET discussion
Post Reply
chad
Posts: 4
Joined: Fri Jan 08, 2010 12:59 pm
Location: USA

filtered databand record count

Post by chad »

How do I tell if a filtered databand has any records? (VB WinForms)
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
I also tried checking in the render event and couldn't seem to get the count there either.

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
chad
Posts: 4
Joined: Fri Jan 08, 2010 12:59 pm
Location: USA

filtered databand record count

Post by chad »

I think I'm a little closer by checking for records in my viewer form in the EndRender event.. but now I'm getting the count of all the records before the filter is applied

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
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

filtered databand record count

Post by Jan »

Hello,

Sorry this information available only during report rendering. You need use Count function in report engine.

Thank you.
Post Reply