可不可以通过函数来建立一个新的控件

解决方案 »

  1.   

    我在编写程序时,有一个FORM中含有一个PIC框,并赋有INDEX值,现在我想在程序运行时动态的创建一个或者更多PIC框
      

  2.   

    Dim WithEvents ctlCommand As VB.CommandButtonPrivate Sub Form_Load()
    Set ctlCommand = Controls.Add("VB.CommandButton", "ctlCommand1", Me)
    '设置CommandButton的位置和尺寸ctlCommand = 400 + 200
    ctlCommand.Left = 20'设置CommandButton的标题
    ctlCommand.Caption = "点击"
    '使CommandButton可见
    ctlCommand.Visible = TrueEnd Sub
      

  3.   

    建立一个已有的控件,然后把index属性设置好,比如0
    然后用Load 语句加载新的控件。如:Load Command1(1)
    然后还要用Command1(1).Visuble=true来显示。
      

  4.   

    '先有form1上加一个picture1 (0)Private Sub Form_Load()
        For i = 1 To 10
            Load Picture1(i)
            Picture1(i).Top = 400 * i + 200
            Picture1(i).Left = 20
            Picture1(i).Visible = True
        Next
    End Sub
      

  5.   

    '先有form1上加一个picture1 (0)Private Sub Form_Load()
        For i = 1 To 10
            Load Picture1(i)
            Picture1(i).Top = 400 * i + 200
            Picture1(i).Left = 20
            Picture1(i).Visible = True
        Next
    End Sub