?? form16.frm
字號:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form Form16
BorderStyle = 1 'Fixed Single
Caption = "Form16"
ClientHeight = 7335
ClientLeft = 45
ClientTop = 435
ClientWidth = 10215
LinkTopic = "Form16"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 7335
ScaleWidth = 10215
StartUpPosition = 3 '窗口缺省
Begin MSAdodcLib.Adodc Adodc1
Height = 615
Left = 2640
Top = 6000
Width = 2535
_ExtentX = 4471
_ExtentY = 1085
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 2
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = $"Form16.frx":0000
OLEDBString = $"Form16.frx":00B6
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "圖書類別"
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋體"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.TextBox Text1
Height = 375
Index = 1
Left = 3600
TabIndex = 10
Top = 1200
Width = 855
End
Begin VB.TextBox Text1
Height = 375
Index = 0
Left = 3720
TabIndex = 9
Top = 360
Width = 855
End
Begin MSComctlLib.ImageList ImageList1
Left = 1440
Top = 480
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 32
ImageHeight = 32
MaskColor = 12632256
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 3
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form16.frx":016C
Key = ""
EndProperty
BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form16.frx":1B93
Key = ""
EndProperty
BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form16.frx":35BA
Key = ""
EndProperty
EndProperty
End
Begin VB.CommandButton Command6
Caption = "退出"
Height = 375
Left = 2760
TabIndex = 8
Top = 4800
Width = 1095
End
Begin VB.CommandButton Command5
Caption = "刪除"
Height = 375
Left = 2760
TabIndex = 7
Top = 4200
Width = 1095
End
Begin VB.CommandButton Command4
Caption = "排序"
Height = 375
Left = 2760
TabIndex = 6
Top = 3600
Width = 1095
End
Begin VB.CommandButton Command3
Caption = "收起"
Height = 375
Left = 2760
TabIndex = 5
Top = 3000
Width = 1095
End
Begin VB.CommandButton Command2
Caption = "展開"
Height = 375
Left = 2760
TabIndex = 4
Top = 2400
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "添加"
Height = 375
Left = 2760
TabIndex = 3
Top = 1800
Width = 1095
End
Begin MSComctlLib.TreeView TreeView1
Height = 3015
Left = 240
TabIndex = 0
Top = 1080
Width = 2055
_ExtentX = 3625
_ExtentY = 5318
_Version = 393217
Style = 7
Appearance = 1
End
Begin VB.Label Label2
Caption = "子"
Height = 495
Left = 2880
TabIndex = 2
Top = 1080
Width = 1095
End
Begin VB.Label Label1
Caption = "父"
Height = 375
Left = 2880
TabIndex = 1
Top = 360
Width = 1095
End
End
Attribute VB_Name = "Form16"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim i As Integer
Dim J As Integer
Dim nodx As Node
Dim CunZai As Boolean '定義變量
Private Sub Command1_Click()
If Text1(0).Text <> "" And Text1(1).Text <> "" Then '不允許建立零字節的父節點和子節點
CunZai = False
J = TreeView1.Nodes.Count
For i = 1 To TreeView1.Nodes.Count '檢查新輸入的父節點名稱是否存在
If TreeView1.SelectedItem.Children > 0 Then
If Text1(0).Text = TreeView1.Nodes(i).Text Then CunZai = True
End If
Next i
If CunZai = True Then '若存在, 則在父節點下建立子節點
Set nodx = TreeView1.Nodes.Add(Text1(0).Text, tvwChild, "child" & J, Text1(1).Text, 3)
Else '若不存在,則建立父節點和子節點
'Set nodx = TreeView1.Nodes.Add(, , Text1(0).Text, Text1(0).Text, 1)
Set nodx = TreeView1.Nodes.Add(Text1(0).Text, tvwChild, "child" & J, Text1(1).Text, 3)
End If
TreeView1.Refresh
ElseIf Text1(0).Text = "" Then MsgBox "請輸入父節點名稱!", vbInformation, "警告!"
'系統提示
ElseIf Text1(1).Text = "" Then MsgBox "請輸入子節點名稱!", vbInformation, "警告!"
End If
Adodc1.Refresh
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields(1) = Text1(1).Text
Adodc1.Recordset.Update
End Sub
Private Sub Command2_Click()
For i = 1 To TreeView1.Nodes.Count
TreeView1.Nodes(i).Expanded = True '展開所有節點
Next i
End Sub
Private Sub Command3_Click()
For i = 1 To TreeView1.Nodes.Count
TreeView1.Nodes(i).Expanded = False '收起所有節點
Next i
End Sub
Private Sub Command4_Click()
TreeView1.Sorted = True '排列順序
End Sub
Private Sub Command5_Click()
If TreeView1.SelectedItem.Index <> 1 Then
TreeView1.Nodes.Remove TreeView1.SelectedItem.Index '刪除選定的節點
End If
End Sub
Private Sub Command6_Click()
End '退出程序
End Sub
Private Sub Form_Load()
TreeView1.LineStyle = tvwTreeLines '在兄弟節點和父節點之間顯示線
TreeView1.ImageList = ImageList1 '鏈接圖像列
TreeView1.Style = tvwTreelinesPlusMinusPictureText
'樹狀外觀包含全部元素
Set nodx = TreeView1.Nodes.Add(, , "圖書類別", "圖書類別", 1)
'建立名稱為"蒲子明"的父節點,選擇索引為1的圖像
'在"蒲子明"父節點下建立"發件箱"子節點,選擇索引為3的圖像
CunZai = False
End Sub
Private Sub TreeView1_Expand(ByVal Node As MSComctlLib.Node)
Node.ExpandedImage = 2 '節點被展開時,選擇索引為2的圖像
End Sub
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
If TreeView1.SelectedItem.Children = 0 Then '檢查是否有子節點,0為無
For i = 1 To TreeView1.Nodes.Count
If TreeView1.Nodes(i).Selected Then
MsgBox "您選擇的是:“" & TreeView1.Nodes(i).FullPath & "”子節點!"
'系統提示
End If
Next i
End If
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -