Articles in this section
Category / Section

How to keep the user from leaving a node in edit mode until they have entered a valid node name in WinForms TreeViewAdv?

1 min read

NodeEditorValidating event

This can be done by handling the TreeViewAdv's NodeEditorValidating event as shown below:

C#

private void treeViewAdv1_NodeEditorValidating_1(object sender, Syncfusion.Windows.Forms.Tools.TreeNodeAdvCancelableEditEventArgs e)
{
   if(e.Label=="Syncfusion")
   {
      e.Cancel = false;
      MessageBox.Show("Valid");
      e.ContinueEditing = false;
   }
   else
   {
      // Cancel the label edit action, inform the user, and place the node in edit mode again
      e.Cancel = true;
      MessageBox.Show("Invalid name");
      // To end editing mode, do this:
      e.ContinueEditing = true;
   }
}

VB

Private Sub treeViewAdv1_NodeEditorValidating_1(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Tools.TreeNodeAdvCancelableEditEventArgs)
   If e.Label="Syncfusion" Then
      e.Cancel = False
      MessageBox.Show("Valid")
      e.ContinueEditing = False
   Else
      ' Cancel the label edit action, inform the user, and place the node in edit mode again.
      e.Cancel = true;
      MessageBox.Show("Invalid name")
      ' To end editing mode, do this:
      e.ContinueEditing = True
   End If
End Sub

 

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