如何动态地将一个控件加载到另一个作为容器的控件上,比如:将一个text加载到sstab上,谢谢

解决方案 »

  1.   

    Option Explicit
    Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As LongPrivate Sub Command1_Click()
        SetParent text1.hWnd, sstab1.hWnd
        text1.Left = 100
        text1.Top = 100
    End Sub
    Private Sub Form_Load()
        text1.Left = 0
        text1.Top = 0
    End Sub
      

  2.   


    Dim WithEvents ctlText As VB.TextBox
    Private Sub Form_Load()
        Set ctlText = Controls.Add("VB.TextBox", "ctlText1", Me)
        '设置Text的位置和尺寸
        
        ctlText.Top = 400 + 200
        ctlText.Left = 20
        
        '设置Text的标题
        ctlText.Text = "点击"
        '使Text可见
        ctlText.Visible = True
        Set ctlText.Container = SSTab1
          
    End Sub