📄 form1.frm
字号:
VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
Begin VB.Form Form1
Caption = "在treeview的节点处使用图形"
ClientHeight = 3585
ClientLeft = 3915
ClientTop = 2730
ClientWidth = 4665
LinkTopic = "Form1"
LockControls = -1 'True
ScaleHeight = 3585
ScaleWidth = 4665
Begin ComctlLib.TreeView TreeView1
Height = 3000
Left = 300
TabIndex = 0
Top = 400
Width = 4095
_ExtentX = 7223
_ExtentY = 5292
_Version = 327682
Indentation = 353
Style = 7
ImageList = "ImageList1"
Appearance = 1
End
Begin VB.Label Label1
Caption = "项目:"
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
' For some convenience...
TreeView1.HideSelection = False
TreeView1.LabelEdit = tvwManual
TreeView1.LineStyle = tvwRootLines
' Fill up the treeview...
For i = 1 To 2
Set Node1 = TreeView1.Nodes.Add(, , , "根目录" & i, 1)
For j = 1 To 3
Set Node2 = TreeView1.Nodes.Add(Node1.Index, tvwChild, , "子目录" & i & "-" & j, 2)
For k = 1 To 3
Set Node3 = TreeView1.Nodes.Add(Node2.Index, tvwChild, , "二级子目录" & (16 * (i - 1)) + (4 * (j - 1)) + k, 3)
Next
Next
Node1.Expanded = True
Next
' Set the labels with the first root Node's text.
' (a NodeClick event is not generated even though the first
' node in the TV is selected when the TV first appears).
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)
Label1 = "项目: " & GetTVItemText(TreeView1.hWnd, hItem)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -