BoxObject Class

Represents a box that has been drawn on the report.

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

Syntax

'Declaration
Public Class BoxObject
    Inherits DrawingObject
    Implements IDisposable
public class BoxObject : DrawingObject, IDisposable

Remarks

This class allows you to retrieve information and set generic format options inherited from the DrawingObject class.

Example

This example retrieves a ReportObject object by name using the Item property of the ReportObjects collection, and casts the ReportObject as a BoxObject. This example also shows how to update the properties of a box object in a ReportDocument.

'Declaration

      Private Function GetBoxObject _
         (ByVal reportObjectName As String) As BoxObject

         Dim box As BoxObject

         If TypeOf _
            (Report.ReportDefinition.ReportObjects. _
            Item(reportObjectName)) Is BoxObject Then
            box = _
               Report.ReportDefinition.ReportObjects. _
               Item(reportObjectName)
            GetBoxObject = box
         Else : GetBoxObject = Nothing
         End If
      End Function

            Private Sub UpdateBoxObjectProperties(ByVal myReportDocument As ReportDocument, ByVal boxObjectName As String, ByVal top As Integer, ByVal left As Integer)
              Dim myReportObject As ReportObject = myReportDocument.ReportDefinition.ReportObjects.Item(boxObjectName)
              If Not myReportObject Is Nothing And myReportObject.Kind = ReportObjectKind.BoxObject Then
                Dim myBoxObject As BoxObject = myReportObject
                myBoxObject.Top = top
                myBoxObject.Left = left
                myBoxObject.EnableExtendToBottomOfSection = True

                myBoxObject.LineColor = Color.Red
                myBoxObject.LineStyle = LineStyle.SingleLine
                myBoxObject.LineThickness = 5
                myBoxObject.FillColor = Color.Green

                Dim myBorder As Border = myBoxObject.Border()
                myBorder.BackgroundColor = Color.White
                myBorder.BorderColor = Color.Red

                Dim myObjectFormat As ObjectFormat = myBoxObject.ObjectFormat
                myObjectFormat.EnableCanGrow = False
                myObjectFormat.EnableSuppress = False
                myObjectFormat.EnableCloseAtPageBreak = True
                myObjectFormat.EnableKeepTogether = True
              End If
      End Sub
      private BoxObject GetBoxObject(string reportObjectName)
      {
         BoxObject box;

         box =
            section.ReportObjects[reportObjectName] as BoxObject;
         return box;
      }

            private void UpdateBoxObjectProperties(ReportDocument reportDocument, String boxObjectName, int top, int left, int height, int width)
            {
              ReportObject reportObject = reportDocument.ReportDefinition.ReportObjects[boxObjectName];
              if (reportObject != null && reportObject.Kind == ReportObjectKind.BoxObject)
              {
                BoxObject boxObject = (BoxObject)reportObject;
                boxObject.Top = top;
                boxObject.Left = left;
                boxObject.EnableExtendToBottomOfSection = true;

                boxObject.LineColor = Color.Red;
                boxObject.LineStyle = LineStyle.SingleLine;
                boxObject.LineThickness = 5;
                boxObject.FillColor = Color.Green;

                Border border = boxObject.Border;
                border.BackgroundColor = Color.White;
                border.BorderColor = Color.Red;

                ObjectFormat objectFormat = boxObject.ObjectFormat;
                objectFormat.EnableCanGrow = false;
                objectFormat.EnableSuppress = false;
                objectFormat.EnableCloseAtPageBreak = true;
                objectFormat.EnableKeepTogether = true;
              }
      }

Inheritance Hierarchy

Object
   EngineObjectBase
      ReportObject
         DrawingObject
            BoxObject

Version Information

Crystal Reports Basic for Visual Studio 2008

Supported since: Crystal Reports for Visual Studio .NET 2002

See Also

Reference

BoxObject Members
CrystalDecisions.CrystalReports.Engine Namespace