📄 form1.frm
字号:
VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
Begin VB.Form Form1
Caption = "Treeview控件特性"
ClientHeight = 5265
ClientLeft = 3915
ClientTop = 2730
ClientWidth = 4815
LinkTopic = "Form1"
LockControls = -1 'True
ScaleHeight = 5265
ScaleWidth = 4815
Begin ComctlLib.TreeView TreeView1
Height = 4065
Left = 300
TabIndex = 0
Top = 870
Width = 4095
_ExtentX = 7223
_ExtentY = 7170
_Version = 327682
Indentation = 353
Style = 7
ImageList = "ImageList1"
Appearance = 1
End
Begin VB.Label Label2
Caption = "Node from item handle:"
Height = 270
Left = 360
TabIndex = 2
Top = 450
Width = 3750
End
Begin VB.Label Label1
Caption = "Item handle from node:"
Height = 270
Left = 360
TabIndex = 1
Top = 90
Width = 3750
End
Begin ComctlLib.ImageList ImageList1
Left = 4200
Top = 90
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 16
ImageHeight = 16
MaskColor = 12632256
_Version = 327682
BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7}
NumListImages = 3
BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "Form1.frx":0000
Key = ""
EndProperty
BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "Form1.frx":031A
Key = ""
EndProperty
BeginProperty ListImage3 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "Form1.frx":0634
Key = ""
EndProperty
EndProperty
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Form_Load()
Dim Node1 As Node
Dim Node2 As Node
Dim Node3 As Node
Dim i As Integer
Dim j As Integer
Dim k As Integer
TreeView1.HideSelection = False
TreeView1.LabelEdit = tvwManual
TreeView1.LineStyle = tvwRootLines
For i = 1 To 2
Set Node1 = TreeView1.Nodes.Add(, , , "Root" & i, 1)
For j = 1 To 3
Set Node2 = TreeView1.Nodes.Add(Node1.Index, tvwChild, , "Root" & i & "Child" & j, 2)
For k = 1 To 3
Set Node3 = TreeView1.Nodes.Add(Node2.Index, tvwChild, , "GrandChild" & (16 * (i - 1)) + (4 * (j - 1)) + k, 3)
Next
Next
Node1.Expanded = True
Next
Call TreeView1_NodeClick(TreeView1.Nodes(1))
End Sub
Private Sub TreeView1_NodeClick(ByVal Node As ComctlLib.Node)
Dim hItem As Long
Dim nod As Node
hItem = GetTVItemFromNode(TreeView1.hWnd, Node)
If hItem Then
Label1 = "Item handle from node: " & GetTVItemText(TreeView1.hWnd, hItem)
Set nod = GetNodeFromTVItem(TreeView1, hItem)
If (nod Is Nothing) = False Then
Label2 = "Node from item handle: " & nod.Text
End If
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -