📄 form1.ebf
字号:
VERSION 5.00
Object = "{D863DA15-8C5B-11D1-86C0-00AA003EE054}#1.0#0"; "mscetreeview.dll"
Begin VB.Form Form1
Appearance = 0 'Flat
BackColor = &H00FFC0FF&
Caption = "Form1"
ClientHeight = 4485
ClientLeft = 60
ClientTop = 840
ClientWidth = 4170
ForeColor = &H80000008&
ScaleHeight = 4485
ScaleWidth = 4170
ShowOK = -1 'True
Begin MSCETREEVIEWLibCtl.TreeViewCtl TreeView1
Height = 3255
Left = 0
TabIndex = 0
Top = 0
Width = 3495
_cx = 6165
_cy = 5741
FontBold = 0 'False
FontItalic = 0 'False
FontName = "Tahoma"
FontSize = 8
FontStrikethrough= 0 'False
FontUnderline = 0 'False
HideSelection = -1 'True
Indentation = 0
LabelEdit = 0
LineStyle = 0
PathSeparator = "\"
Style = 7
Enabled = -1 'True
End
Begin VBCE.TextBox Text1
Height = 375
Left = 1680
TabIndex = 5
Top = 3240
Width = 1815
_cx = 3201
_cy = 661
BackColor = -2147483643
BorderStyle = 1
Enabled = -1 'True
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = -2147483640
Text = ""
Alignment = 0
HideSelection = -1 'True
Locked = 0 'False
MaxLength = 0
MultiLine = 0 'False
PasswordChar = ""
ScrollBars = 0
End
Begin VBCE.Label Label1
Height = 375
Left = 240
TabIndex = 4
Top = 3240
Width = 1455
_cx = 2566
_cy = 661
AutoSize = 0 'False
BackColor = 16761024
BackStyle = 1
BorderStyle = 0
Caption = "Node Count"
Enabled = -1 'True
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = -2147483640
Alignment = 0
UseMnemonic = -1 'True
WordWrap = 0 'False
End
Begin VBCE.CommandButton Command1
Height = 375
Left = 240
TabIndex = 3
Top = 3600
Width = 855
_cx = 1508
_cy = 661
BackColor = 12632256
Caption = "Add"
Enabled = -1 'True
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Tahoma"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Style = 0
End
Begin VBCE.CommandButton Command2
Height = 375
Left = 1320
TabIndex = 2
Top = 3600
Width = 975
_cx = 1720
_cy = 661
BackColor = 12632256
Caption = "Remove"
Enabled = -1 'True
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Tahoma"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Style = 0
End
Begin VBCE.CommandButton Command3
Height = 375
Left = 2520
TabIndex = 1
Top = 3600
Width = 975
_cx = 1720
_cy = 661
BackColor = 12632256
Caption = "Clear"
Enabled = -1 'True
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Tahoma"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Style = 0
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim nodX As Node '声明 Node 变量。
Dim nodx_child As Node
Private Sub Command1_Click()
Set nodX = TreeView1.Nodes.Add("r", tvwChild, "child5", "结点" & TreeView1.Nodes.Count + 1)
Set nodx_child = TreeView1.Nodes.Add("child5", tvwChild, "child" & TreeView1.Nodes.Count + 1 & 1, "结点" & TreeView1.Nodes.Count + 1 & "_子结点1")
Set nodx_child = TreeView1.Nodes.Add("child5", tvwChild, "child" & TreeView1.Nodes.Count + 1 & 2, "结点" & TreeView1.Nodes.Count + 1 & "_子结点2")
Set nodx_child = TreeView1.Nodes.Add("child5", tvwChild, "child" & TreeView1.Nodes.Count + 1 & 3, "结点" & TreeView1.Nodes.Count + 1 & "_子结点3")
Text1.Text = TreeView1.Nodes.Count
End Sub
Private Sub Command2_Click()
TreeView1.Nodes.Remove (5)
Text1.Text = TreeView1.Nodes.Count
End Sub
Private Sub Command3_Click()
TreeView1.Nodes.Clear
Text1.Text = TreeView1.Nodes.Count
End Sub
Private Sub Form_Load()
TreeView1.LineStyle = tvwRootLines ' Linestyle 1
'添加 Node 对象。
'带有文本 'Root' 的第一个节点。
Set nodX = TreeView1.Nodes.Add(, , "r", "根结点")
'下一个节点是节点 1 ("Root") 的子节点。
Set nodX = TreeView1.Nodes.Add("r", tvwChild, "child1", "结点1")
Set nodx_child = TreeView1.Nodes.Add("child1", tvwChild, "child11", "子结点1_子结点1")
Set nodx_child = TreeView1.Nodes.Add("child1", tvwChild, "child12", "子结点1_子结点2")
Set nodx_child = TreeView1.Nodes.Add("child1", tvwChild, "child13", "子结点1_子结点3")
Set nodX = TreeView1.Nodes.Add("r", tvwChild, "child2", "结点2")
Set nodx_child = TreeView1.Nodes.Add("child2", tvwChild, "child21", "结点2_子结点1")
Set nodx_child = TreeView1.Nodes.Add("child2", tvwChild, "child22", "结点2_子结点2")
Set nodx_child = TreeView1.Nodes.Add("child2", tvwChild, "child23", "结点2_子结点3")
Set nodX = TreeView1.Nodes.Add("r", tvwChild, "child3", "结点3")
Set nodx_child = TreeView1.Nodes.Add("child3", tvwChild, "child31", "子结点3_子结点1")
Set nodx_child = TreeView1.Nodes.Add("child3", tvwChild, "child32", "子结点3_子结点2")
Set nodx_child = TreeView1.Nodes.Add("child3", tvwChild, "child33", "子结点3_子结点3")
Set nodX = TreeView1.Nodes.Add("r", tvwChild, "child4", "结点4")
Set nodx_child = TreeView1.Nodes.Add("child4", tvwChild, "child41", "结点4_子结点1")
Set nodx_child = TreeView1.Nodes.Add("child4", tvwChild, "child42", "结点4_子结点2")
Set nodx_child = TreeView1.Nodes.Add("child4", tvwChild, "child43", "结点4_子结点3")
Dim i As Integer
For i = 1 To TreeView1.Nodes.Count
TreeView1.Nodes(i).EnsureVisible
Next
Text1.Text = TreeView1.Nodes.Count
End Sub
Private Sub Form_OKClick()
App.End
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -