Search code examples
vb.netactivereportscomponentone

Hide or ignore rows based on data


Depending on a value in a field on the report, I want to decide whether to display the entire row or not. I know that I could mark the Visible property on the Field/TextBox control to false, but that won't hide the entire row (e.g. such as the Detail Section). I am using VB.NET 2.0 and ActiveReports 4. Any pointers?


Solution

  • By "row" I'm assuming you mean a Section. You can hide a section by setting the Visible property of the Section object to false. You could use code something like the following.

    Note: This code needs to be in the Format event of the Section that you're hiding.

    If Me.txtReorderLevel.Value = 0 And Me.txtDiscontinued.Value = False Then
        Me.Detail1.Visible = True ' Detail1 is a reference to the Section to hide
    Else
        Me.Detail.Visible = False
    End If
    

    There is also a how to topic in the help that describes this scenario. However, this is from the newest version of ActiveReports which also includes page-layout reports so the namespaces are slightly different. The code for Section reports is the same however.