Skip to main content Skip to footer

Implement CanGrow Functionality for Surrounding Shapes

Many times users come and ask for the CanGrow property of the Shape control in ActiveReports. Basically, this requirement arises for a shape, which surrounds Textboxes and requires to grow whenever the Textboxes inside it grows. As of now, ActiveReports 7.0 does not have any property to support this implementation. However, this can be easily implemented through code. The simpler approach would be:

  1. Iterate through all the Textboxes surrounded by the Shape control.
  2. Find the height of the tallest Textbox.
  3. Set the height of the Shape control surrounding the Textboxes to the said height.

Following code snippet implements the above steps:


private void detail_BeforePrint(object sender, EventArgs e)  
{  
    GrapeCity.ActiveReports.SectionReportModel.Detail d = default(GrapeCity.ActiveReports.SectionReportModel.Detail);  
    d = this.detail;  

    int i = 0;  
    float h = 0;  

    for (i = 0; i <= d.Controls.Count - 1; i++)  
    {  
          GrapeCity.ActiveReports.SectionReportModel.ARControl ctrl = d.Controls[i];  

          if (ctrl is GrapeCity.ActiveReports.SectionReportModel.TextBox)  
              if (ctrl.Height > h)  
                 h = ctrl.Height;  
     }  

     this.shape1.Height = h + 0.1f;  
 }  

Refer to the attached samples for complete implementation. Download C# Sample Download VB Sample

MESCIUS inc.

comments powered by Disqus