Returns a reference to the report's sections collection.
Return Type
Sections collection.
Remarks
This property can be used to add or remove report sections at run time.
Example
[C#]
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 Basic]
Private Sub constructReport()
Try
Me.Detail.CanGrow = True
Me.Detail.CanShrink = True
Me.Detail.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.Detail.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.Detail.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
ActiveReport Class
| ActiveReport Members
| Walkthrough: Creating and Modifying Report Layouts at Run Time
Copyright © 2004-2005 Data Dynamics, Ltd. All rights reserved.