line、 shape 控件的大小、位置的这些属性不都有的吗?你在程序中设置就可以了。
如果需要随时添加,减少的话可以使用数组控件的。

解决方案 »

  1.   

    private sub command1_click()
    Line1.X1=0
    Line1.X2=1200
    Line1.Y1=30
    Line1.Y2=30shape1.Left=0
    shape1.top=0
    shape1.width=450
    shape1.height=450
      

  2.   

    private sub command1_click()
    Line1.X1=0
    Line1.X2=1200
    Line1.Y1=30
    Line1.Y2=30shape1.Left=0
    shape1.top=0
    shape1.width=450
    shape1.height=450
    end sub
      

  3.   

    由于shape, line等在运行时不能作为container,无法产生事件,所以你应当在它的container(form,..?)中捕捉MouseDown event, 检查是否在它的形状内部,如果是,就跟踪mouseMove, 算出它的位置,调用它的move方法,移到新位置,mouseUp时取消捕捉。
    下面是个简单的示例,实际的判断要复杂一些:Dim m As Boolean
    Dim px, pyPrivate Sub Form_Load()
    m = False
    End SubPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If X > Shape1.Left And X < Shape1.Width + Shape1.Left Then
        m = True
        px = X
        py = Y
        
    End IfEnd SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If m = True Then
        Shape1.Move X - px + Shape1.Left, Y - py + Shape1.Top
        px = X
        py = Y
    End If
    End SubPrivate Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    m = False
    End Sub
      

  4.   

    例如:Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Shape1.Left = X
    Shape1.Top = Y
    End Sub
      

  5.   

    onestab
    还想问一下,我怎样才知鼠标当前所选的是line(index),还是shape(index)?
    是不是我用picturebox预载图片(先定义好的,能代替line shape的),也可实现同样的效果?但问题是我有可能加载上1000个同样的控件,会不会影响程序的运行?
      

  6.   

    如果你的形状较多,还要考虑分层问题-保证使后面的shape也能被选中。
    图片框占用的资源较多,不推荐使用。
    速度最快,最节省资源的办法就是设计自己的shape类。用多少就new多少。