ActiveReports Developer 7
Sections Property
See Also  Example
GrapeCity.ActiveReports.v7 Assembly > GrapeCity.ActiveReports Namespace > SectionReport Class : Sections Property

Glossary Item Box

Returns a reference to the report's sections collection.

Syntax

Visual Basic (Declaration) 
Public ReadOnly Property Sections As SectionCollection
C# 
public SectionCollection Sections {get;}

Property Value

Sections collection.

Remarks

This property can be used to add or remove report sections at run time.

Example

C#Copy Code
float m_defaultHeight = .2f;
float m_defaultWidth = 4f;
float m_currentY = 0f;
        
private void constructReport()
{
    try
    {
        this.detail.CanGrow = true;
        this.detail.CanShrink = true;
        this.detail.KeepTogether = true;

        if(m_useGroups)
        {
            this.Sections.InsertGroupHF();
            ((GroupHeader)this.Sections["groupHeader1"]).DataField = "Country";
            this.Sections["groupHeader1"].BackColor = System.Drawing.Color.SlateBlue;
            this.Sections["groupHeader1"].CanGrow = true;
            this.Sections["groupHeader1"].CanShrink = true;
            ((GroupHeader)this.Sections["groupHeader1"]).RepeatStyle = RepeatStyle.OnPageIncludeNoDetail;
            this.Sections["groupFooter1"].Height = 0;

            TextBox txt = new TextBox();
            txt.DataField = "Country";
            txt.Location = new System.Drawing.PointF(0f,0);
            txt.Width =2f;
            txt.Height = .3f;
            txt.Style = "font-weight: bold; font-size: 16pt;";
            this.Sections["groupHeader1"].Controls.Add(txt);

        }
                
        for(int i=0;i<m_arrayFields.Count;i++)
        {
            if(!m_useGroups || (m_useGroups && m_arrayFields[i].ToString() != "Country"))
            {
                Label lbl = new Label();
                lbl.Text = m_arrayFields[i].ToString() + ":";
                lbl.Location = new System.Drawing.PointF(0f,m_currentY);
                lbl.Width =.9f;
                lbl.Height = m_defaultHeight;
                this.detail.Controls.Add(lbl);

                TextBox txt = new TextBox();
                txt.DataField = m_arrayFields[i].ToString();
                txt.Location = new System.Drawing.PointF(1f,m_currentY);
                txt.Width =m_defaultWidth;
                txt.Height = m_defaultHeight;
                this.detail.Controls.Add(txt);
                
                m_currentY = m_currentY + m_defaultHeight;
            }
        }
    }
    catch(Exception ex)
    {
        System.Windows.Forms.MessageBox.Show("Error in Report-constructReport: " + ex.Message,"Project Error",System.Windows.Forms.MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Error);
    }
}
Visual BasicCopy Code
Private Sub constructReport()
    Try
        Me.Detail1.CanGrow = True
        Me.Detail1.CanShrink = True
        Me.Detail1.KeepTogether = True
        If m_useGroups = True Then
            Me.Sections.InsertGroupHF()

            CType(Me.Sections("GroupHeader1"), GroupHeader).DataField = "CategoryID"
            Me.Sections("GroupHeader1").BackColor = System.Drawing.Color.SlateBlue
            Me.Sections("GroupHeader1").CanGrow = True
            Me.Sections("GroupHeader1").CanShrink = True
            CType(Me.Sections("GroupHeader1"), GroupHeader).RepeatStyle = RepeatStyle.OnPageIncludeNoDetail
            Me.Sections("GroupHeader1").Height = 0

            Dim txt As New TextBox()
            txt.DataField = "CatagoryID"
            txt.Location = New System.Drawing.PointF(0.0F, 0)
            txt.Width = 2.0F
            txt.Height = 0.3F
            txt.Style = "font-weight: bold; font-size: 16pt"
            Me.Sections("GroupHeader1").Controls.Add(txt)
        End If
        For i = 0 To m_arrayFields.Count - 1
           If (m_useGroups = False) Or (m_useGroups AndAlso m_arrayFields(i).ToString <> "CategoryID") Then

                Dim lbl As New Label()
                lbl.Text = m_arrayFields(i) + ":"
                lbl.Location() = New System.Drawing.PointF(0.0F, m_currentY)
                lbl.Width() = 0.9F
                lbl.Height = m_defaultHeight
                Me.Detail1.Controls.Add(lbl)

                Dim txt As New TextBox()
                txt.DataField = m_arrayFields(i)
                txt.Location = New System.Drawing.PointF(1.0F, m_currentY)
                txt.Width = m_defaultWidth
                txt.Height = m_defaultHeight
                Me.Detail1.Controls.Add(txt)
                If m_arrayFields(i) = "UnitPrice" Then
                    txt.OutputFormat = "$#.00"
                End If
                m_currentY = m_currentY + m_defaultHeight
            End If
        Next
    Catch ex As Exception
        System.Windows.Forms.MessageBox.Show("Error in Report-constructReport: " + ex.Message, "Project Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error)
    End Try
End Sub

See Also