Search
ShapeListBox Class
Remarks See Also
 





The ShapeListBox control displays a set of shapes defined via the Shape class.

Namespace: MindFusion.Diagramming.WinForms
Assembly: MindFusion.Diagramming.WinForms.Controls

 Syntax

C#  Copy Code

public class ShapeListBox : ListBox

Visual Basic  Copy Code

Public Class ShapeListBox
    Inherits ListBox

 Remarks

In order to use the ShapeListBox control, customize the Visual Studio toolbox and add a reference to MindFusion.Diagramming.WinForms.ShapeListBox.dll.

Shapes from the list box can be dragged to the DiagramView drawing canvas to create new shape nodes. Changing the shape of an existing node can be implemented by handling the ShapeSelected event and assigning the selected shape to the Shape property of a node.

Initially, the ShapeListBox displays all shapes accessible via Shape.FromId. You could limit the list only to a subset of the available shapes by setting the ShapeFilter property. It is also possible to load a shape library from a file using the ShapeLibrary class, and display the loaded shapes as shown below:

C#  Copy Code

ShapeLibrary lib = ShapeLibrary.LoadFrom("shapeLib.shl");
shapeList.Shapes = lib.Shapes;

The control creates an icon image for each shape added. The size of an icon displayed in the list box can be defined via the IconSize property, and IconMargin specifies the horizontal and vertical margin of the icon. The shape's DisplayName is displayed as a label near the icon.

If the AllowRename property is set to true, users can press the F2 key and rename a shape in the list box. When a shape is renamed, the ShapeRenamed event is raised. If the AllowRemove property is enabled, list box items can be deleted by pressing the DEL key. When a shape is removed, the ShapeRemoved event is raised.

 Inheritance Hierarchy

System.Object
    System.MarshalByRefObject
        System.ComponentModel.Component
            System.Windows.Forms.Control
                System.Windows.Forms.ListControl
                    System.Windows.Forms.ListBox
                        MindFusion.Diagramming.WinForms.ShapeListBox

 See Also