SubreportObject Class
Represents a subreport placed in a report.
Namespace CrystalDecisions.CrystalReports.Engine Assembly CrystalDecisions.CrystalReports.Engine (CrystalDecisions.CrystalReports.Engine.dll)
Syntax
'Declaration
Public Class SubreportObject
Inherits ReportObject
Implements IDisposable
public class SubreportObject : ReportObject, IDisposable
Remarks
A subreport is a freestanding or linked report found within the main report. This class allows you to retrieve information and set generic format options inherited from the ReportObject class, as well as allowing you to open the subreport as a ReportDocument.
Retrieve a ReportObject object by index or by name through the Item Property of the ReportObjects collection, and cast the ReportObject as a SubreportObject.
Example
This example gets a SubreportObject object by name and updates its properties.
'Declaration
Private Sub UpdateSubreportObjectProperties(ByVal myReportDocument As ReportDocument, ByVal subreportObjectName As String, ByVal top As Integer, ByVal left As Integer, ByVal height As Integer, ByVal width As Integer)
Dim myReportObject As ReportObject = myReportDocument.ReportDefinition.ReportObjects.Item(subreportObjectName)
If Not myReportObject Is Nothing And myReportObject.Kind = ReportObjectKind.SubreportObject Then
Dim mySubreportObject As SubreportObject = myReportObject
mySubreportObject.Top = top
mySubreportObject.Left = left
mySubreportObject.Height = height
mySubreportObject.Width = width
mySubreportObject.EnableOnDemand = True
Dim myBorder As Border = mySubreportObject.Border()
myBorder.BackgroundColor = Color.White
myBorder.BorderColor = Color.Red
Dim myObjectFormat As ObjectFormat = mySubreportObject.ObjectFormat
myObjectFormat.EnableCanGrow = False
myObjectFormat.EnableSuppress = False
myObjectFormat.EnableCloseAtPageBreak = True
myObjectFormat.EnableKeepTogether = True
End If
End Sub
private void UpdateSubreportObjectProperties(ReportDocument reportDocument, String subreportObjectName, int top, int left, int height, int width)
{
ReportObject reportObject = reportDocument.ReportDefinition.ReportObjects[subreportObjectName];
if (reportObject != null && reportObject.Kind == ReportObjectKind.SubreportObject)
{
SubreportObject subreportObject = (SubreportObject)reportObject;
subreportObject.Top = top;
subreportObject.Left = left;
subreportObject.Height = height;
subreportObject.Width = width;
subreportObject.EnableOnDemand = true;
Border border = subreportObject.Border;
border.BackgroundColor = Color.White;
border.BorderColor = Color.Red;
ObjectFormat objectFormat = subreportObject.ObjectFormat;
objectFormat.EnableCanGrow = false;
objectFormat.EnableSuppress = false;
objectFormat.EnableCloseAtPageBreak = true;
objectFormat.EnableKeepTogether = true;
}
}
Inheritance Hierarchy
Object
EngineObjectBase
ReportObject
SubreportObject
Version Information
Crystal Reports Basic for Visual Studio 2008
Supported since: Crystal Reports for Visual Studio .NET 2002
See Also
Reference
SubreportObject Members
CrystalDecisions.CrystalReports.Engine Namespace