Dragging a control

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tull Clancey

    #1

    Dragging a control

    Does anyone have, or can anyone suggest a URL for code to drag a control
    around a form at run time? VB.Net 2003.

    I have written stuff in VB6 to do this before, but a long time ago and I
    don't have the code to refer to anymore.

    Cheers,
    Tull.


  • Peter Proost

    #2
    Re: Dragging a control

    This is sample code for dragging a button at runtime, should be easy to
    modify for other controls

    Hope this helps
    <<<<<<code>>>>> >


    Private dragging As Boolean
    Private beginX, beginY As Integer


    Private Sub Button2_MouseDo wn(ByVal sender As Object, ByVal e As _
    System.Windows. Forms.MouseEven tArgs) Handles Button2.MouseDo wn


    dragging = True
    beginX = e.X
    beginY = e.Y


    End Sub


    Private Sub Button2_MouseMo ve(ByVal sender As Object, ByVal e As _
    System.Windows. Forms.MouseEven tArgs) Handles Button2.MouseMo ve
    If dragging = True Then
    Button2.Locatio n = New Point(Button2.L ocation.X + e.X -
    beginX,Button2. Location.Y + e.Y - beginY)
    Me.Refresh()
    End If
    End Sub


    Private Sub Button2_MouseUp (ByVal sender As Object, ByVal e As _
    System.Windows. Forms.MouseEven tArgs) Handles Button2.MouseUp


    dragging = False


    End Sub






    --
    Programming today is a race between software engineers striving to build
    bigger and better idiot-proof programs, and the Universe trying to produce
    bigger and better idiots. So far, the Universe is winning. (Rich Cook)

    "Tull Clancey" <tull.clancey@b topenworld.com> schreef in bericht
    news:KMGdnT3P88 loMQfZRVnygw@bt .com...[color=blue]
    > Does anyone have, or can anyone suggest a URL for code to drag a control
    > around a form at run time? VB.Net 2003.
    >
    > I have written stuff in VB6 to do this before, but a long time ago and I
    > don't have the code to refer to anymore.
    >
    > Cheers,
    > Tull.
    >
    >[/color]


    Comment

    • Cor Ligthert [MVP]

      #3
      Re: Dragging a control

      Hi Tull,



      I hope this helps,

      Cor

      "Tull Clancey" <tull.clancey@b topenworld.com> schreef in bericht
      news:KMGdnT3P88 loMQfZRVnygw@bt .com...[color=blue]
      > Does anyone have, or can anyone suggest a URL for code to drag a control
      > around a form at run time? VB.Net 2003.
      >
      > I have written stuff in VB6 to do this before, but a long time ago and I
      > don't have the code to refer to anymore.
      >
      > Cheers,
      > Tull.
      >[/color]


      Comment

      Working...