GrapeCity ActiveReports for .NET 14.0J
Sections プロパティ
使用例 

GrapeCity.ActiveReports アセンブリ > GrapeCity.ActiveReports 名前空間 > SectionReport クラス : Sections プロパティ
レポートのセクションコレクションへの参照を返します。
シンタックス
'宣言
 
Public ReadOnly Property Sections As SectionCollection
public SectionCollection Sections {get;}

プロパティ値

Sectionsコレクション。

解説

このプロパティは、実行時にレポートセクションを追加したり、削除したりするために使用します。

使用例
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);
    }
}
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
参照

SectionReport クラス
SectionReport メンバ

基本操作

実行時レポートの作成手順