Category / Section
Create Palette with GroupNode where GroupNode contain multiple ControlNodes.
2 mins read
Create Palette with GroupNode where GroupNode contain multiple ControlNodes.
In diagram control, we can add a group object with contains multiple ControlNode into the symbol palette.
The following codes illustrates to adding the group with multiple ControlNode to the palette.
[C#]
//initializing the label control System.Windows.Forms.Label label = new System.Windows.Forms.Label(); label.Size = new System.Drawing.Size(200, 25); label.Text = "Label"; label.Name ="Label"; label.TextAlign = ContentAlignment.MiddleCenter; //initializing the textbox control TextBox textbox = new TextBox(); textbox.MinimumSize = new System.Drawing.Size(200, 400); textbox.Text = "TextBox"; textbox.Name = "TextBox"; //adding a textbox to diagram's control node ControlNode textboxCtrlNode = new ControlNode(textbox, new RectangleF(0, 0, 200, 100)); textboxCtrlNode.Name = "TextBoxControl"; textboxCtrlNode.ActivateStyle = ActivateStyle.ClickPassThrough; //adding a label to diagram's control node ControlNode labelCtrlNode = new ControlNode(label, new RectangleF(0, 100, 200, 25)); labelCtrlNode.ActivateStyle = ActivateStyle.ClickPassThrough; labelCtrlNode.Name = "LabelControl"; Group group = new Group(); group.Name = "GroupNode"; //adding symbols to group node group.AppendChild(textboxCtrlNode); group.AppendChild(labelCtrlNode); diagram1.Model.AppendChild(group); //adding symbols to palette SymbolPalette symbol = new SymbolPalette(); symbol.AppendChild(group); paletteGroupBar1.AddPalette(symbol);
[VB]
'initializing the label control Dim label As New System.Windows.Forms.Label() label.Size = New System.Drawing.Size(200, 25) label.Text = "Label" label.Name ="Label" label.TextAlign = ContentAlignment.MiddleCenter 'initializing the textbox control Dim textbox As New TextBox() textbox.MinimumSize = New System.Drawing.Size(200, 400) textbox.Text = "TextBox" textbox.Name = "TextBox" 'adding a textbox to diagram's control node Dim textboxCtrlNode As New ControlNode(textbox, New RectangleF(0, 0, 200, 100)) textboxCtrlNode.Name = "TextBoxControl" textboxCtrlNode.ActivateStyle = ActivateStyle.ClickPassThrough 'adding a label to diagram's control node Dim labelCtrlNode As New ControlNode(label, New RectangleF(0, 100, 200, 25)) labelCtrlNode.ActivateStyle = ActivateStyle.ClickPassThrough labelCtrlNode.Name = "LabelControl" Dim group As New Group() group.Name = "GroupNode" 'adding symbols to group node group.AppendChild(textboxCtrlNode) group.AppendChild(labelCtrlNode) diagram1.Model.AppendChild(group) 'adding symbols to palette Dim symbol As New SymbolPalette() symbol.AppendChild(group) paletteGroupBar1.AddPalette(symbol)