Form mit anderem Steuerelement bewegen

  • VB.NET

Es gibt 3 Antworten in diesem Thema. Der letzte Beitrag () ist von lee.

    Form mit anderem Steuerelement bewegen

    Hallo,

    Ich habe folgende frage :

    kann man VB anweisen das die Form mit einem steuerelement bewegt wird?

    Also zum Beispiel mit einer PictureBox wenn man darauf klickt,festhaltet und mit der maus zieht, so das die form mitbewegt wird?

    so wie bei programmen wo anstatt der standard windows fensterleiste mit den schliessen,maximieren und minimieren button eine picturebox verwendet wird und man damit das fenster ziehen kann.

    bitte um eine antwort.

    Grüße, Lee
    Mit dem MouseDown event würde ich es mal versuchen!

    EDIT: mal so als ansatz:

    VB.NET-Quellcode

    1. Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
    2. PictureBox1.Location = New Drawing.Point(e.X, e.Y)
    3. End Sub

    VB.NET-Quellcode

    1. Private ptMouseDownLocation As Point
    2. Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
    3. If e.Button = Windows.Forms.MouseButtons.Left Then
    4. ptMouseDownLocation = e.Location
    5. End If
    6. End Sub
    7. Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
    8. If e.Button = Windows.Forms.MouseButtons.Left Then
    9. Me.Location = e.Location - ptMouseDownLocation + Me.Location
    10. End If
    11. End Sub