如何将控件加载到指定的容器控件中?

双井巷 2003-07-03 09:12:25
我写了个用户控件,其中有个picturebox控件。在程序运行时,想动态加载一些控件到picturebox中,可是每次只能加载到用户控件上。想请教有什么方法可以实现加载控件到指定的容器控件中?
...全文
159 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
双井巷 2003-07-08
  • 打赏
  • 举报
回复
有谁知道,还请多多指教!
双井巷 2003-07-08
  • 打赏
  • 举报
回复
我要做一个用户控件udtScroll,里面有个picturebox。
需要在程序运行时动态加载其他的控件到这个picturebox 中,
可是每次只能加到用户控件上,无法加到picturebox上。
请教高手,有什么解决办法?
双井巷 2003-07-07
  • 打赏
  • 举报
回复
我的源程序,这是一个Active 控件,现在想在调用的过程中将其他控件加到Active控件的picture1中。可是加*的地方总是出错。请高手指教!
Option Explicit
Private intCurPosition As Integer

Private Sub UserControl_Initialize()

With Picture1
.AutoSize = True
.BorderStyle = 0
End With

With VScroll1
.Min = 0
.Max = Picture1.Height - UserControl.ScaleHeight
.SmallChange = 50
.LargeChange = 350
.Value = 0
If .Max > 0 Then
.Visible = True
.Enabled = True
Else
.Visible = False
.Enabled = False
End If
End With
intCurPosition = 0
End Sub

********************************************************
Private Sub UserControl_InitProperties()
UserControl.ContainedControls = True
UserControl.ContainerHwnd = Picture1.hWnd
End Sub
******************************************************

Private Sub UserControl_Resize()
With VScroll1
.Top = 0
.Width = 240
.Left = UserControl.Width - .Width
.Height = UserControl.Height
End With

With Picture1
.Top = 0
.Left = 0
.Width = UserControl.Width - VScroll1.Width
.Height = UserControl.Height
End With
End Sub

Private Sub VScroll1_Change()
With Picture1
.Move .Left, .Top - VScroll1.Value + intCurPosition
End With
intCurPosition = VScroll1.Value
End Sub
rainstormmaster 2003-07-03
  • 打赏
  • 举报
回复
Option Explicit
Dim WithEvents mytextbox As TextBox
Private Sub Command1_Click()
Set mytextbox = Controls.Add("vb.textbox", "mytextbox", Picture1)
mytextbox.Left = 50
mytextbox.Top = 50
mytextbox.Visible = True

End Sub
fs_windy 2003-07-03
  • 打赏
  • 举报
回复
控件的Container属性
下面是将按钮command1放到Picture1上

Set Command1.Container = Picture1
jordi2014 2003-07-03
  • 打赏
  • 举报
回复
Dim WithEvents mytextbox As TextBox
Private Sub Command1_Click()
Set mytextbox = Controls.Add("vb.textbox", "mytextbox", Picture1)
mytextbox.Left = 50
mytextbox.Top = 50
mytextbox.Visible = True

End Sub

1,451

社区成员

发帖
与我相关
我的任务
社区描述
VB 控件
社区管理员
  • 控件
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧