共用方式為


SubreportObject 類別

代表置於報表中的子報表。子報表是出現在主報表中的一個獨立的或連結的報表。這個類別可以讓您擷取資訊並設定繼承自 ReportObject 類別的泛用格式選項,並且讓您將子報表開啟為 ReportDocument

如需這個類型所有成員的清單,請參閱 SubreportObject 成員

Object

   ReportObject

      SubreportObject

[Visual Basic]

Public Class SubreportObject
   Inherits ReportObject

[C#]

public class SubreportObject : ReportObject

[C++]

__gc public class SubreportObject : public ReportObject

[VJ#]

public class SubreportObject extends ReportObject

註解

透過 ReportObjects 集合的 Item 屬性依索引或名稱來擷取 ReportObject 物件,並將 ReportObject 轉換 SubreportObject

範例

下列範例會傳回 SubreportObject 物件。

[Visual Basic]

Private Function GetSubreportObject _ 
(ByVal reportObjectName As String) As SubreportObject
   Dim subreport As SubreportObject

   ' 依名稱取得 ReportObject,將之轉換為 SubreportObject,
   '  然後將它傳回來。
   If TypeOf _
   (Report.ReportDefinition.ReportObjects. _ 
   Item(reportObjectName)) Is SubreportObject Then
      subreport = _ 
      Report.ReportDefinition.ReportObjects. _ 
      Item(reportObjectName)
      GetSubreportObject = subreport
   Else : GetSubreportObject = Nothing
   End If
End Function

[C#]

private SubreportObject GetSubreportObject
(string reportObjectName) 
{
   SubreportObject subreport;

   // 依名稱取得 ReportObject,將之轉換為 SubreportObject,
   //  然後將它傳回來。
   subreport = 
   Report.ReportDefinition.ReportObjects[reportObjectName] 
   as SubreportObject;
   if (subreport != null) return subreport;
   else return null;
}

[C++]

SubreportObject* GetSubreportObject(String* reportObjectName)
{
   SubreportObject* subreport;

   // 依名稱取得 SubreportObject,將之轉換為 SubreportObject,
   // 然後將它傳回來。
   try
   {
      subreport = __try_cast<SubreportObject*>
      (Report->ReportDefinition->
      ReportObjects->Item[reportObjectName]);
      return subreport;
   }
   catch(System::InvalidCastException*)
   {
      return 0;
   }
};

[VJ#]

private SubreportObject GetSubreportObject
(String reportObjectName) 
{
   SubreportObject subreport;

   // 依名稱取得 ReportObject,將之轉換為 SubreportObject,
   //  然後將它傳回來。
   subreport = (SubreportObject)
Report.get_ReportDefinition().get_ReportObjects().get_Item(reportObjectName);
   if (subreport != null) return subreport;
   else return null;
}

需求

命名空間CrystalDecisions.CrystalReports.Engine

**平台:**Windows 98、Windows NT 4.0、Windows Millennium Edition、Windows 2000

**組件:**CrystalDecisions.Crystalreports.Engine (CrystalDecisions.Crystalreports.Engine.dll)

請參閱

SubreportObject 成員 | CrystalDecisions.CrystalReports.Engine 命名空間