In ReoGrid worksheets, most content — including data and certain object types — is typically contained within cells. However, floating objects are an exception; they are not associated with specific cells and can be positioned freely at absolute locations on the worksheet.

Floating Objects in ReoGrid

Floating objects in ReoGrid include a variety of elements such as Drawing Shapes, Images, and Charts. These objects are unified by their inheritance from the FloatingObject base class, allowing them to exist independently of the cell grid and to be positioned and manipulated as discrete entities within the worksheet space.

Class Hierarchy of Floating Objects

The hierarchy of floating object classes in ReoGrid is structured as follows:

  • FloatingObject: The base class for all floating elements within the worksheet.
    • DrawingObject: A subclass for drawable elements, serving as the parent for specific shapes and lines.
      • ShapeObject: Encapsulates common properties and behaviors of shape objects.
        • RectangleShape: Defines a rectangle shape.
        • EllipseShape: Defines an ellipse shape.
        • RoundedRectangleShape: Defines a rectangle with rounded corners.
        • PieShape: Represents a pie section shape.
        • DiamondShape: Represents a diamond shape.
      • Line: Represents a straight line.
      • ImageObject: Embeds an image within the worksheet as a floating object.
      • DrawingComponent: A broader category encompassing components such as charts.
        • Chart: The base class for chart objects, providing foundational chart functionality.
          • LineChart: Represents a line chart.
          • ColumnChart: Represents a column chart.
          • BarChart: Represents a bar chart.
          • AreaChart: Represents an area chart.
          • Pie2DChart: Represents a two-dimensional pie chart.

Create a Floating Object

The following code creates a rectangle object:

var rectObj = new Drawing.Shapes.RectangleShape()
{
  // set the location of the rectangle
  Location = new Graphics.Point(50, 50),

  // set the size of the rectangle
  Size = new Graphics.Size(200, 100),
};

Add a Floating Object

To add a floating object to a worksheet, add the object to the FloatingObjects collection of the worksheet:

// get the currently selected worksheet
var worksheet = control.CurrentWorksheet;

// add the rectangle to the worksheet
worksheet.FloatingObjects.Add(rectObj);

Result: 262

Floating Image

261

To add an image to a worksheet, see Floating Image.

Was this article helpful?