CreateShape (Method)

Applies To:

Shapes collection

Description:

CreateShape(bqShapeType, [sectionName])

To programmatically create a shape on a dashboard, use the CreateShape function. The first parameter specifies the sort of shape or control to be created and must be one of the values of the bqShapeType enumeration.

If the shape being created is an embedded section the section parameter must be the name of the section to be embedded. This must be a chart, pivot, result set, or table. If the name of any other type of section is supplied the function fails and an exception is thrown.

When creating shapes using COM, you must supply a value for the second parameter. You can supply the empty string “” for this value for shapes and controls other than embedded sections.

Shapes are created at the top-left of the dashboard section, with a default size based on type of shape or control. The default size is the same size used when the same type of shape is dragged onto the dashboard in Design mode.

A reference to the newly created shape is returned from this function. You can use the reference to set the Placement of the shape using the Placement properties or functions, and you can set the name of the shape using the Name property.

Note:

Using more than 1,021 shapes is not supported in a Dashboard section.

Example:

This example creates a rectangular shape as a goal, called LeftGoal, sets the placement properties, and colors the rectangle black.

var objRect = ActiveSection.Shapes.CreateShape(bqRectangle)
objRect.Name = "LeftGoal"
objRect.Placement.XOffset = Field.Placement.XOffset - 10
objRect.Placement.YOffset = Field.Placement.YOffset - 10
objRect.Placement.Width = Ball.Placement.Width - 60
objRect.Placement.Height = Field.Placement.Height + 20
objRect.Fill.Color = bqBlack