The Box class represents diagram nodes that can have distinct shapes. Boxes might represent nodes in a graph, tree, process diagram, etc.
VB6
![]() |
---|
Public Class Box |
C++
![]() |
---|
class Box |
The shape of a box is specified via the Style property. Style value can be set to a member of the EBoxStyle enumeration, which provides several simple shape styles such as Ellipse and Rectangle. If Style is set to bsShape, a more elaborate shape can be assigned to a box through the Shape property. The latter style also lets boxes to be rotated, either interactively using the rotation handle above the box, or programmatically using the RotationAngle property.
Boxes can have incoming and outgoing arrows attached, which are accessible through the IncomingArrows and OutgoingArrows collections. The points from which arrows are allowed to go out from a box or come into a box can be defined via AnchorPattern.
Constraints upon how users are allowed to modify a box are set through the Constraints and MnpHandlesMask properties. The former specifies constraints on move direction and box size. The latter enables or disables specific manipulation handles of the box.
A text string can be associated with a box via the Text property. That string is painted using the box' Font and TextColor. Control over the placement and layout of the text is provided by the TextStyle property. Laying out text in non-rectangular box outlines and using styled text is possible for boxes whose Style is set to bsShape or bsPolygon. The EnableStyledText property allows using HTML-like formatting tags to apply various attributes to any part of the text string. Use PlainText to get text without the embedded formatting tags. The FitSizeToText method resizes a box so that it is just big enough to contain its text entirely.
Apart from the main textual content set in Text, you can add supplementary labels by creating NodeLabel objects and calling AddLabel.
The border and decoration lines of a box are drawn with the colors set in FrameColor and DecorationColor. The box is filled according to the values of FillStyle, FillColor and FillColor2. The box could display an image as specified in Picture and PicturePos. The shadow offset can be changed through ShadowOffsetX and ShadowOffsetY. A box can be made Transparent to have only its text or picture visible, or it can be completely hidden by setting Visible to false.
A box can be partially or fully custom-drawn, as specified via the CustomDraw property. Handle the CustomDraw event to draw the custom visual elements of a box. Call the Repaint method to redraw a custom-drawn box after its related data changes. You can also use that method to create animations.
Boxes can form hierarchical structures that can be expanded or collapsed by a user or programmatically. That is controlled via the following methods and properties: Collapse, Expand, Expandable, Expanded.
User data can be attached to a box via the Tag and VariantTag properties.