哪位知道除了form外,treeview、frame等上能不能动态创建控件??? load txt(1)set txt(1).container=frame1txt(1).visible=true 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 如果按楼上的理解其实在添加的时候,只要txt是从属于Frame的那么以后动态添加的txt都是从属于Frame的! ''定义一个控件数组 第一个为 txt(0)load txt(1) ''load数组中第2个控件set txt(1).container=frame1 ''将该控件数组的容器定为frame1txt(1).visible=true ''在容器上显示控件这是个很好的方法啊 现在方法可以不用控件数组来实现动态装载控件下面的示例是演示动态加载一个PICTRUE控件,其他的我给出了控件类型,你自己试着做吧,举一反三一看类型就明白是什么控件Option ExplicitDim oControl As ObjectPrivate Sub Command1_Click()Dim oControlType As StringDim oControlName As StringoControlType = "VB.PictureBox"'oControlType = "VB.CommandButton"'oControlType = "VB.CheckBox"'oControlType = "RichText.RichTextCtrl"oControlName = "picLoad"Set oControl = Controls.Add(oControlType, oControlName)oControl.Width = 400oControl.Height = 300oControl.Left = 5'(ScaleWidth - oControl.Width) / 2oControl.Top = 5'(ScaleHeight - oControl.Height) / 2oControl.Visible = TrueCommand2.Enabled = TrueCommand1.Enabled = FalseEnd SubPrivate Sub Command2_Click()oControl.Picture = LoadPicture(App.Path & "\1.jpg")End SubPrivate Sub Command3_Click()EndEnd Sub VBA中如何获取选中区域的值,并将选中的值导出到一个Excel中 如何动态添加菜单项! vb中treeview如何处理多级分类和任意移动节点,删除父节点。 关于DataGrid下标越界 VB怎样能直接从数据库中直接存取图片??? VB的最新发现!! 他一定很爱你 怎样在main函数中传出参数。我要写一个没有窗口的.exe执行文件,main是sub,怎样传出结果? 如何调用DLL里含有指针参数的API函数 在VB中如何输出双引号 高手请教,Printer对象使用问题 如何把滚动条和richtextbox控件结合使用
其实在添加的时候,只要txt是从属于Frame的
那么以后动态添加的txt都是从属于Frame的!
''定义一个控件数组 第一个为 txt(0)load txt(1) ''load数组中第2个控件
set txt(1).container=frame1 ''将该控件数组的容器定为frame1
txt(1).visible=true ''在容器上显示控件
这是个很好的方法啊
下面的示例是演示动态加载一个PICTRUE控件,其他的我给出了控件类型,你自己试着做吧,举一反三
一看类型就明白是什么控件Option Explicit
Dim oControl As ObjectPrivate Sub Command1_Click()
Dim oControlType As String
Dim oControlName As String
oControlType = "VB.PictureBox"
'oControlType = "VB.CommandButton"
'oControlType = "VB.CheckBox"
'oControlType = "RichText.RichTextCtrl"oControlName = "picLoad"
Set oControl = Controls.Add(oControlType, oControlName)
oControl.Width = 400
oControl.Height = 300
oControl.Left = 5
'(ScaleWidth - oControl.Width) / 2
oControl.Top = 5
'(ScaleHeight - oControl.Height) / 2
oControl.Visible = True
Command2.Enabled = True
Command1.Enabled = False
End SubPrivate Sub Command2_Click()
oControl.Picture = LoadPicture(App.Path & "\1.jpg")
End SubPrivate Sub Command3_Click()
End
End Sub