Articles in this section
Category / Section

Hide Label Context Menu toolbar on Double Click

1 min read

 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)
 

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied