Shrink DataBand row height dynamically

edited 11:35PM in FastReport .NET
Hi, Here is my scenario.

I've a DataBand in my report binded to List of object A in my DataSource.
There are two text objects inside the DataBand (TextA and TextB).
Now according to a boolean property (IsValid) in object A, I want to hide one of the text box and adjust the height of the each DataBand row.

For example
if(IsValid == true), display both text objects, so the row looks like this
Text A
Text B

if(IsValid == false), row should like this
Text B

So far I've set the
CanShrink
property of DataBand to true and wrote a script on code page
private void Data1_BeforeLayout(object sender, EventArgs e)
    {
      
      if(((Boolean)Report.GetColumnValue("Root.ObjectA.IsValid")) == false)
      {
        TextA.Visible = false;
        TextB.Visible = true;
      }
      else
      {
        TextA.Visible = true;
        TextB.Visible = true;         
      }                                     
    }
and hooked it to DataBand's BeforeLayout Event


But this only results in report looking like this
(Valid row)
Text A
Text B
(Invalid row)
[Blank white space here ]
Text B
(InValid row)
[Blank white space here ]
Text B

Whereas I want it to look like this

(Valid row)
Text A
Text B
(Invalid row)
Text B
(Invalid row)
Text B


Hope the question is clear .. Thanks

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.