Search
ControlNode Class
Remarks See Also
 





ControlNode instances represent diagram nodes which can host .NET controls.

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

 Syntax

C#  Copy Code

public class ControlNode : DiagramNode

Visual Basic  Copy Code

Public Class ControlNode
    Inherits DiagramNode

 Remarks

A ControlNode instance might be used to implement advanced entity viewers or editors. An instance of any .NET Windows.Form.Control-derived class can be assigned to the Control property of the host. That might be a standard .NET control such as a DataGrid or your own custom or user control.

If the Behavior property of DiagramView is set to DrawControls or LinkControls, then users are allowed to draw control host nodes interactively. Such host nodes will have their Control initialized to an instance of the type specified via DefaultControlType.

If a user presses the mouse button while the mouse pointer is over a hosted control, MindFusion.Diagramming will either pass the mouse event to the control, or will try to intercept it in order to start moving or resizing the host node. That depends on the value of the ControlMouseAction property.

 Performance note

If many ControlNode objects must be created consecutively, enclose the calls to Nodes.Add between SuspendLayout and ResumeLayout. Consider the sample code in the example section.

That example ensures that the OnLayout method is executed only once; otherwise it would be executed after each call to Nodes.Add. The .NET Framework invokes OnLayout when the positions of form controls change or when controls are added to or removed from a form. The DiagramView class overrides that method to update the location and size of its scrollbars, which however could lead to unnecessary delay if the method is called for each new ControlNode added.

 Example

The following example illustrates how to add many ControlNode instances to the diagram without causing a layout pass for each individual control:

C#  Copy Code

diagView.SuspendLayout();

for (int i = 0; i < 500; ++i)
{
    ControlNode host = new ControlNode(diagView);
    host.Bounds = new RectangleF((i % 10) * 40, (i / 10) * 40, 30, 30);
    diag.Nodes.Add(host);
}

diagView.ResumeLayout();

Visual Basic  Copy Code

diagView.SuspendLayout()

Dim i As Integer
For i = 0 To 499

    Dim host As ControlNode = New ControlNode(diagView)
    host.Bounds = New RectangleF((i Mod 10) * 40, (i / 10) * 40, 30, 30)
    diag.Nodes.Add(host)

Next

diagView.ResumeLayout()

 Inheritance Hierarchy

System.Object
    MindFusion.Diagramming.DiagramItem
        MindFusion.Diagramming.DiagramNode
            MindFusion.Diagramming.WinForms.ControlNode

 See Also