📄 form1.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Begin VB.Form Form1
BorderStyle = 4 'Fixed ToolWindow
Caption = "+"
ClientHeight = 4905
ClientLeft = 45
ClientTop = 225
ClientWidth = 9225
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4905
ScaleWidth = 9225
ShowInTaskbar = 0 'False
StartUpPosition = 3 '窗口缺省
Begin VB.TextBox Text1
Height = 2970
Left = 3270
MultiLine = -1 'True
TabIndex = 2
Text = "Form1.frx":0000
Top = 1035
Width = 5100
End
Begin VB.CommandButton Command1
Caption = "导出(&T)"
Height = 330
Left = 3360
TabIndex = 1
Top = 420
Width = 1755
End
Begin MSComctlLib.ImageList ImageList1
Left = 2010
Top = 1920
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 16
ImageHeight = 16
MaskColor = 16777215
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 3
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":0006
Key = ""
EndProperty
BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":011A
Key = ""
EndProperty
BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":022E
Key = ""
EndProperty
EndProperty
End
Begin MSComctlLib.TreeView Trw1
Height = 4860
Left = 15
TabIndex = 0
Top = 30
Width = 2940
_ExtentX = 5186
_ExtentY = 8573
_Version = 393217
Style = 7
ImageList = "ImageList1"
Appearance = 1
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Function ExportTrToString(Treeview As Treeview, Optional StartNode As Node) As String
Dim TvText As String
Dim nd As Node
Dim childNd As Node
Dim i As Integer
Static Leave As Integer
If Treeview.Nodes.Count = 0 Then Exit Function
If StartNode Is Nothing Then
Set nd = Treeview.Nodes(1).Root.FirstSibling
Else
Set nd = StartNode
End If
TvText = String$(Leave, vbTab) & nd.Text & vbCrLf
If nd.Children And nd.Expanded Then
Leave = Leave + 1
Set childNd = nd.Child
For i = 1 To nd.Children
TvText = TvText & ExportTrToString(Treeview, childNd)
Set childNd = childNd.Next
Next
Leave = Leave - 1
End If
If StartNode Is Nothing Then
Set nd = nd.Next
Do Until nd Is Nothing
TvText = TvText & ExportTrToString(Treeview, nd)
Loop
End If
ExportTrToString = TvText
End Function
Private Sub Command1_Click()
Text1.Text = ExportTrToString(Trw1)
End Sub
Private Sub Form_Load()
With Trw1
.Nodes.Add , , "MY Computer", "My Computer"
.Nodes.Add "MY Computer", tvwChild, "child1", "child1"
.Nodes.Add "MY Computer", tvwChild, "child2", "child2"
.Nodes.Add "MY Computer", tvwChild, "child3", "child3"
.Nodes.Add "child1", tvwChild, "child4", "child4"
.Nodes.Add "child1", tvwChild, "child5", "child5"
End With
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -