Share via


ReportDocument.SetCssClass Method

Sets the cascading style sheet (CSS) for various sections and report objects.

Namespace CrystalDecisions.CrystalReports.Engine Assembly CrystalDecisions.CrystalReports.Engine (CrystalDecisions.CrystalReports.Engine.dll)

Syntax

'Declaration
Public Overrideable Sub SetCssClass ( _
    ByVal objectScope As CrystalDecisions.Shared.ObjectScope, _ 
    ByVal cssClass As String _  
) 
public virtual void SetCssClass (
    CrystalDecisions.Shared.ObjectScope objectScope,
    string cssClass
)

Parameters

  • objectScope
    Indicates the section or sections of the report that the style class will apply to. For example, set the style for the whole report, or set the style for the Report Header section.
  • cssClass
    The name of the style class as defined in the style sheet.

Remarks

The style class can be used to override the object and section formats contained in the report. Set the style class for reports that will be viewed using the CrystalReportViewer control.

Example

This example sets the style class for the details section of a report.

'Declaration

      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
         myReportDocument.SetCSSClass(scope, styleName)
      End Sub
      
      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;
         };
         reportDocument->SetCSSClass(scope, styleName);
      };
      
      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;
         }
         reportDocument.SetCSSClass(scope, styleName);
      }
      

Version Information

Crystal Reports Basic for Visual Studio 2008

Supported since: Crystal Reports for Visual Studio .NET 2002

See Also

Reference

ReportDocument Class
ReportDocument Members
CrystalDecisions.CrystalReports.Engine Namespace