Hide Label Context Menu toolbar on Double Click
Hide Label’s Default Menu toolbar on Double Click
In Syncfusion® Diagram, the Node has a default property that displays the label editor for the node along with the label's default menu while double-clicking. To disable the label's default menu for the entire diagram, it can be achieved by setting the diagram.Controller’s InPlaceEditing to false.
The following code example illustrates on how to disable the label editor for particular node.
[C#]
diagram1.Controller.InPlaceEditing = false;
[VB]
diagram1.Controller.InPlaceEditing = false;
To show the TextBox alone while double-clicking a node, a new TextBox must be created, and it must be shown at the time of double-clicking a node.
The below code snippet shows how to create a text node.
[C#]
System.Windows.Forms.TextBox txtLabel; txtLabel = new System.Windows.Forms.TextBox(); txtLabel.Location = new System.Drawing.Point(100,100); txtLabel.Multiline = true; txtLabel.Name = "txtLabel"; txtLabel.Size = new System.Drawing.Size(105, 46); txtLabel.TabIndex = 0;
[VB]
Dim txtLabel As System.Windows.Forms.TextBox txtLabel = New System.Windows.Forms.TextBox() txtLabel.Location = New System.Drawing.Point(100,100) txtLabel.Multiline = True txtLabel.Name = "txtLabel" txtLabel.Size = New System.Drawing.Size(105, 46) txtLabel.TabIndex = 0
The below code snippet is used to Register the Nodes double click event in the diagram.
[C#]
this.diagram1.EventSink.NodeDoubleClick += EventSink_NodeDoubleClick;
[VB]
Me.diagram1.EventSink.NodeDoubleClick += EventSink_NodeDoubleClick
While double clicking over the node the created text box must appear. So that the label’s default menu won’t appears.
The below code snippet is used to render the newly created text box at the time of NodeDoubleClick.
[C#]
this.txtLabel.Location =new Point((int)diagram1.Controller.MouseLocation.X,(int)diagram1.Controller.MouseLocation.Y); this.diagram1.Controls.Add(txtLabel); // Displays the created TextBox txtLabel.Show();
[VB]
Me.txtLabel.Location = New Point(CInt(Fix(diagram1.Controller.MouseLocation.X)),CInt(Fix(diagram1.Controller.MouseLocation.Y))) Me.diagram1.Controls.Add(txtLabel) ‘ Displays the created TextBox txtLabel.Show()
The below code snippet is used to hide the newly created TextBox while clicking over the diagram.
[C#]
txtLabel.Hide(); this.diagram1.Controls.Remove(txtLabel);
[VB]
txtLabel.Hide() Me.diagram1.Controls.Remove(txtLabel)
Conclusion
I hope you enjoyed learning about how to Hide Label Context Menu toolbar on Double Click.
You can refer to our WinForms Diagram feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WinForms Diagram example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!