We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Hide Label Context Menu toolbar on Double Click

Platform: WinForms |
Control: Diagram |
Published Date: November 25, 2015 |
Last Revised Date: June 2, 2019 |
Product Version: 12.4.0.24

 Hide Label’s Default Menu toolbar on Double Click

In Syncfusion Diagram the Node has a default property that it will displays the label editor for the node along with the labels default menu while double clicking.To disable the labels default menu for 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 click 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)
 

 

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon