Print Parameters only if exists

Hello,

sorry for my english .

I wanted to know if there is a way to print a parameter conditionally. I try to explain myself better, in my case we have a print of an order from a customer of a restaurant. The condition should be if the "allergies" parameter has been written then it must print the line "allergies: [Allergies] otherwise it must not print anything. This is in order to make the report shorter once printed. In your opinion it is possible ?


I am a newbie so thank you very much for the attention.


Comments

  • Hello!

    Move the optional TextObject to a separate ChildBand (or a separate DataBand / ReportTitle).

    Set the CanShrink property of this ChildBand to true (if you need to shrink the contents) and hide the band itself in the BeforePrint event or via VisibleExpression:

    private void ChildAllergies_BeforePrint(object sender, EventArgs e)
    {
    string val = Convert.ToString(Report.GetParameterValue(‘Allergies’));
    ChildAllergies.Visible = !string.IsNullOrWhiteSpace(val);
    }
    

    When ChildAllergies.Visible == false, the band following it automatically moves up without leaving an empty gap.

This discussion has been closed.