ReportDocument.SetCssClass 方法

为各种节和报表对象设置级联式样式表 (CSS)。

[Visual Basic]

Public Overrideable Sub SetCssClass( _
   ByVal objectScope As CrystalDecisions.Shared.ObjectScope, _
   ByVal cssClass As String _
)

[C#]

public virtual void SetCssClass(
   CrystalDecisions.Shared.ObjectScope objectScope, 
   string cssClass
);

参数

  • objectScope
    指明报表中样式类将应用的节。例如,为整个报表设置样式,或为“报表页眉”节设置样式。

  • cssClass
    样式表中定义的样式类的名称。

备注

样式类可用于替代报表中包含的对象格式和节格式。为使用 CrystalReportViewer 控件查看的报表设置样式类。

示例

下面的示例为报表的详细资料部分设置样式类。示例首先设置样式类的范围值,然后应用该样式。

  
[VJ#]
      private void setReportStyle(String styleName, char section) 
      {
         ObjectScope scope;
         switch(section)
         {
            case 'R':
               scope = 
                  ObjectScope.AllReportObjectsInGroupHeaderSections;
               break;
            case 'G':
               scope = 
                  ObjectScope.AllReportObjectsInGroupFooterSections;
               break;
            case 'D':
               scope = ObjectScope.AllReportObjectsInDetailSections;
               break;
            default:
               scope = ObjectScope.AllSections;
               break;
         }
         Report.SetCssClass(scope, styleName);
      }
      
  
[Visual Basic]
      Private Sub SetReportStyle _
         (ByVal styleName As String, ByVal section As String)
      
         Dim scope As New ObjectScope()
         Select Case (section)
            Case "GroupHeader"
               scope = _
                  ObjectScope.AllReportObjectsInGroupHeaderSections
            Case "GroupFooter"
               scope = _
                  ObjectScope.AllReportObjectsInGroupFooterSections
            Case "Detail"
               scope = ObjectScope.AllReportObjectsInDetailSections
            Case Else
               scope = ObjectScope.AllSections
         End Select
         Report.SetCSSClass(scope, styleName)
      End Sub 
      
  
[C++]
      void SetReportStyle(String* styleName, char section) 
      {
         ObjectScope scope;
      
         switch(section)
         {
            case 'R'
               scope = ObjectScope::AllReportObjectsInReportHeaderSections;
               break;
            case 'G':
               scope = ObjectScope::AllReportObjectsInGroupHeaderSections;
               break;
            case 'D':
               scope = ObjectScope::AllReportObjectsInDetailSections;
               break;
            default:
               scope = ObjectScope::AllSections;
               break;
         };
         Report->SetCSSClass(scope, styleName);
      }; 
      
  
[C#]
      private void SetReportStyle(string styleName, string section) 
      {
         ObjectScope scope = new ObjectScope();
         switch(section)
         {
            case "GroupHeader":
               scope = 
                  ObjectScope.AllReportObjectsInGroupHeaderSections;
               break;
            case "GroupFooter":
               scope = 
                  ObjectScope.AllReportObjectsInGroupFooterSections;
               break;
            case "Detail":
               scope = ObjectScope.AllReportObjectsInDetailSections;
               break;
            default:
               scope = ObjectScope.AllSections;
               break;
         }
         Report.SetCSSClass(scope, styleName);
      }
      

要求

命名空间 CrystalDecisions.CrystalReports.Engine

程序集 CrystalDecisions.CrystalReports.Engine (CrystalDecisions.CrystalReports.Engine.dll)

请参见

ReportDocument 类 | ReportDocument 成员 | CrystalDecisions.CrystalReports.Engine 命名空间

**

©2005 Business Objects SA 保留所有权利。

Business Objects SA
http://www.china.businessobjects.com/
支持服务
http://www.china.businessobjects.com/