本文整理汇总了VB.NET中System.Windows.Forms.TreeView.BeforeLabelEdit事件的典型用法代码示例。如果您正苦于以下问题:VB.NET TreeView.BeforeLabelEdit事件的具体用法?VB.NET TreeView.BeforeLabelEdit怎么用?VB.NET TreeView.BeforeLabelEdit使用的例子?那么恭喜您, 这里精选的事件代码示例或许可以为您提供帮助。您也可以进一步了解该事件所在类System.Windows.Forms.TreeView
的用法示例。
在下文中一共展示了TreeView.BeforeLabelEdit事件的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: InitializeTreeView
Private Sub InitializeTreeView()
' Construct the TreeView object.
Me.TreeView1 = New System.Windows.Forms.TreeView
' Set dock, location, size name, and tab order
' values for the TreeView object.
With TreeView1
.Dock = System.Windows.Forms.DockStyle.Left
.Location = New System.Drawing.Point(0, 0)
.Name = "TreeView1"
.Size = New System.Drawing.Size(152, 266)
.TabIndex = 1
End With
' Set the LabelEdit property to true to allow the
' user to edit the TreeNode text.
Me.TreeView1.LabelEdit = True
' Declare and create objects needed to populate
' the TreeView.
Dim file, files(), filePath As String
files = New String() {"bigPresentation.ppt", "myFinances.xls", _
"myResume.doc"}
filePath = "c:\myFiles"
Dim nodes As New System.Collections.ArrayList
' Create a node for each file, setting the Text property to the
' file's name and the Tag property to file's fully-qualified name.
For Each file In files
Dim node As New TreeNode(file)
node.Tag = filePath & "\" & file
nodes.Add(node)
Next
' Create a new node named topNode and add the ArrayList of
' nodes to topNode.
Dim topNode As New TreeNode("myFiles", _
nodes.ToArray(GetType(TreeNode)))
topNode.Tag = filePath
' Add topNode to the TreeView.
TreeView1.Nodes.Add(topNode)
' Add the TreeView to the form.
Me.Controls.Add(TreeView1)
End Sub
Private Sub TreeView1_BeforeLabelEdit(ByVal sender As Object, _
ByVal e As NodeLabelEditEventArgs) Handles TreeView1.BeforeLabelEdit
' Determine whether the user has selected the top node. If so,
' change the CancelEdit property to true to cancel the edit.
If (e.Node Is TreeView1.TopNode) Then
e.CancelEdit = True
MessageBox.Show("You are not allowed to edit the top node")
End If
End Sub
示例2: Case
' Handle the After_Select event.
Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.TreeViewEventArgs) _
Handles TreeView1.AfterSelect
' Vary the response depending on which TreeViewAction
' triggered the event.
Select Case (e.Action)
Case TreeViewAction.ByKeyboard
MessageBox.Show("You like the keyboard!")
Case TreeViewAction.ByMouse
MessageBox.Show("You like the mouse!")
End Select
End Sub