Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleAllow the user to edit some but not all nodes in a TreeView control in VB .NET
KeywordsTreeView, VB.NET, edit label, edit node
CategoriesControls, VB.NET
 
Set the control's LabelEdit property to True to allow the user to edit the control's labels.

In the control's BeforeLabelEdit event handler, decide whether the user should be allowed to edit the selected node's label and set e.CancelEdit to False to prevent the edit. This example prevents the user from editing nodes at the top of the tree.

 
' Do not allow the user to edit the root nodes.
Private Sub trvOrg_BeforeLabelEdit(ByVal sender As Object, _
    ByVal e As System.Windows.Forms.NodeLabelEditEventArgs) _
    Handles trvOrg.BeforeLabelEdit
    e.CancelEdit = _
        (e.Node.FullPath.IndexOf(trvOrg.PathSeparator) = -1)
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated