In ReoGrid worksheets, most content, including data and certain object types, is typically contained within cells. However, floating objects are an exception; they do not associate 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 a 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 like charts.
- Chart: The base class for chart objects, providing foundational chart functionalities.
- 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.
- Chart: The base class for chart objects, providing foundational chart functionalities.
- ShapeObject: Encapsulates common properties and behaviors of shape objects.
- DrawingObject: A subclass for drawable elements, serving as a parent for specific shapes and lines.
Create Floating Object
The following code creates a rectangle object:
var rectObj = new Drawing.Shapes.RectangleShape()
{
// set the location of rectangle
Location = new Graphics.Point(50, 50),
// set the size of rectangle
Size = new Graphics.Size(200, 100),
};
Add Floating Object
To add a floating object onto worksheet, put the object into the collection FloatingObjects
of worksheet:
// get current selected worksheet
var worksheet = control.CurrentWorksheet;
// adding rectangle on worksheet
worksheet.FloatingObjects.Add(rectObj);
Result:
Floating Image
To add an images on worksheet, see Floating Image.