本文整理匯總了VB.NET中System.Windows.Forms.TreeView.AfterSelect事件的典型用法代碼示例。如果您正苦於以下問題:VB.NET TreeView.AfterSelect事件的具體用法?VB.NET TreeView.AfterSelect怎麽用?VB.NET TreeView.AfterSelect使用的例子?那麽, 這裏精選的事件代碼示例或許可以為您提供幫助。您也可以進一步了解該事件所在類System.Windows.Forms.TreeView
的用法示例。
在下文中一共展示了TreeView.AfterSelect事件的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: 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
示例2: MainClass
' 導入命名空間
Imports System
Imports System.Collections
Imports System.Data
Imports System.Drawing
Imports System.Windows.Forms
Imports System.ComponentModel
Imports System.Drawing.Drawing2D
Imports System.IO
Public Class MainClass
Shared Sub Main()
Dim form1 As Form = New Form1
Application.Run(form1)
End Sub
End Class
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents treeFood As System.Windows.Forms.TreeView
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.treeFood = New System.Windows.Forms.TreeView()
Me.SuspendLayout()
'
'treeFood
'
Me.treeFood.Anchor = (((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right)
Me.treeFood.ImageIndex = -1
Me.treeFood.Location = New System.Drawing.Point(4, 4)
Me.treeFood.Name = "treeFood"
Me.treeFood.SelectedImageIndex = -1
Me.treeFood.Size = New System.Drawing.Size(284, 256)
Me.treeFood.TabIndex = 0
'
'TreeViewExample
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 14)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.treeFood})
Me.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Name = "TreeViewExample"
Me.Text = "TreeView Example"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub TreeViewExample_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim node As TreeNode
node = treeFood.Nodes.Add("Node")
node.Nodes.Add("Leap 1")
node.Nodes.Add("Leap 2")
node = treeFood.Nodes.Add("Node 2")
node.Nodes.Add("Leap 3")
node.Nodes.Add("Leap 4")
End Sub
Private Sub treeFood_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles treeFood.AfterSelect
If e.Action = TreeViewAction.ByMouse Then
MessageBox.Show(e.Node.FullPath)
End If
End Sub
End Class