📄 非引用控件的动态创建.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 4290
ClientLeft = 60
ClientTop = 390
ClientWidth = 8130
LinkTopic = "Form1"
ScaleHeight = 4290
ScaleWidth = 8130
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 585
Left = 5745
TabIndex = 0
Top = 2460
Width = 1830
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim WithEvents NewTreeView As VBControlExtender '声明一个在VB IDE中通用的ActiveX类型
Attribute NewTreeView.VB_VarHelpID = -1
Private Sub Command1_Click()
On Error Resume Next
Dim treeid As String
treeid = Licenses.Add("mscomctllib.treectrl.2") '用Licenses集合的add方法查找非引用控件的许可证字符串
Licenses.Add "mscomctllib.treectrl.2", treeid '向Licenses集合中添加非引用控件的许可证
Set NewTreeView = Controls.Add("mscomctllib.treectrl.2", "tree")
NewTreeView.Move 200, 200, 1600, 2500
NewTreeView.TabStop = True
NewTreeView.Visible = True
End Sub
Private Sub newtreeview_ObjectEvent(Info As EventInfo)
Select Case Info.Name '检查Info参数的Name属性以确定什么事件被激发(这称为后绑定事件)
Case "Click"
MsgBox "这是单击事件"
Case "KeyPress"
MsgBox "这是键盘事件"
End Select
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -