Areas.Item Property (String)
Gets the object with the specified name. In C#, this property is the indexer for the Areas class.
Namespace CrystalDecisions.CrystalReports.Engine Assembly CrystalDecisions.CrystalReports.Engine (CrystalDecisions.CrystalReports.Engine.dll)
Syntax
'Declaration
Public Overrideable ReadOnly Property Item ( _
ByVal fieldName As String _
) As CrystalDecisions.CrystalReports.Engine.Area
public virtual CrystalDecisions.CrystalReports.Engine.Area this [
string fieldName
]{get;}
Parameters
- fieldName
Property Value
The value in the collection with the specified name.
Remarks
This property allows you to access a specific item in the collection. The item is referenced by the object name, such as "object1".
The property name Item does not exist for C#. To access an item in a collection using C#, use the syntax: collection["object1"].
Example
This example shows how to center all PageHeader sections in a specified area.
'Declaration
Private Sub CenterReportObjects(ByVal myReportDocument As ReportDocument, ByVal areaName As String)
Dim myReportDefinition As ReportDefinition = myReportDocument.ReportDefinition()
Dim myAreas As Areas = myReportDefinition.Areas()
Dim myArea As Area = myAreas.Item(areaName)
Dim mySections As Sections = myArea.Sections()
Dim mySection As Section
For Each mySection In mySections
If mySection.Kind = AreaSectionKind.PageHeader Then
If mySection.SectionFormat.EnableSuppressIfBlank = False Then
Dim myReportObjects As ReportObjects = mySection.ReportObjects()
Dim myReportObject As ReportObject
For Each myReportObject In myReportObjects
myReportObject.ObjectFormat.HorizontalAlignment = Alignment.HorizontalCenterAlign
Next
End If
End If
Next
End Sub
private void CenterReportObjects(ReportDocument reportDocument, String areaName)
{
ReportDefinition reportDefinition = reportDocument.ReportDefinition;
Areas areas = reportDefinition.Areas;
Area area = reportDefinition.Areas[areaName];
if (area != null)
{
Sections sections = area.Sections;
for (int i=0; i<sections.Count; i++)
{
Section section = sections[i];
if (section.Kind == AreaSectionKind.PageHeader)
{
if (section.SectionFormat.EnableSuppressIfBlank == false)
{
ReportObjects reportObjects = section.ReportObjects;
for (int j=0; j<reportObjects.Count; j++)
{
ReportObject reportObject = reportObjects[j];
reportObject.ObjectFormat.HorizontalAlignment = Alignment.HorizontalCenterAlign;
}
}
}
}
}
}
Version Information
Crystal Reports Basic for Visual Studio 2008
Supported since: Crystal Reports for Visual Studio .NET 2002
See Also
Reference
Areas Class
Areas Members
CrystalDecisions.CrystalReports.Engine Namespace