我自己写了一个控件,运行时,我点击这个控件的内部区域,可以生成一个新的控件,但是这个新的控件有一部份区域看不见。怎么让自己写的控件增大来完整显示新的控件,同样当去除新的控件时,怎么缩小自己的控件,必须在程序运行时完成。请那位vb高手指教下

解决方案 »

  1.   

    用控件属性管理器添加一个属性,在得到属性函数里面根据属性值ReSize就解决你的问题了.
      

  2.   

    新建一个用户自定义控件,新建一个文本框,index属性设置为0,新建一个按钮,然后把以下代码粘贴到用户控件中,看看效果Option ExplicitDim mCount As Long
    Private Sub Command1_Click()
         mCount = mCount + 1
         Load Text1(mCount)
         Text1(mCount).Move Text1(mCount - 1).Left, Text1(mCount - 1).Top + Text1(mCount - 1).Height + 200
         UserControl.Height = Text1(mCount).Top + Text1(mCount).Height + 100
         Text1(mCount).Visible = True
    End Sub
      

  3.   

    新建一个用户自定义控件,新建一个文本框,index属性设置为0,新建一个按钮,然后把以下代码粘贴到用户控件中,看看这个是不是你想要的Option ExplicitDim mCount As Long
    '新增
    Private Sub Command1_Click()
         mCount = mCount + 1
         Load Text1(mCount)
         Text1(mCount).Move Text1(mCount - 1).Left, Text1(mCount - 1).Top + Text1(mCount - 1).Height + 200
         UserControl.Height = Text1(mCount).Top + Text1(mCount).Height + 100
         Text1(mCount).Visible = True
    End Sub
    '缩小
    Private Sub Command2_Click()
        If mCount > 0 Then
            Unload Text1(mCount)
            mCount = mCount - 1
            UserControl.Height = Text1(mCount).Top + Text1(mCount).Height + 100
        End If
    End Sub