title: how can i drag any label in vb
body: <p>I want to drag any label that is created in VB form. Is that possible if use a code to create a label?</p>
  
  <p>For example: I have 20 labels and they are all different names. Is there a code that can let me drag any label I click on with the cursor I used that code it works but it only drags those labels that I created earlier but if I use a code to create labels is there a way to drag those:</p>
  
  <p>code for dragging 1 label </p>
  
  <p>code for click and drag 1 label only that was added in edit view </p>
  
  <pre><code>Private Sub obj1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)  'varocarbas
          ' Check if the mouse is down
          If Go = True Then
              ' Set the mouse position
              HoldLeft = (Control.MousePosition.X - Me.Left)
              HoldTop = (Control.MousePosition.Y - Me.Top)
              ' Find where the mouse was clicked ONE TIME
              If TopSet = False Then
                  OffTop = HoldTop - sender.Top
                  ' Once the position is held, flip the switch
                  ' so that it doesn't keep trying to find the position
                  TopSet = True
              End If
              If LeftSet = False Then
                  OffLeft = HoldLeft - sender.Left
                  ' Once the position is held, flip the switch
                  ' so that it doesn't keep trying to find the position
                  LeftSet = True
              End If
              ' Set the position of the object
              sender.Left = HoldLeft - OffLeft
              sender.Top = HoldTop - OffTop
          End If
  
      End Sub
  </code></pre>
  
  <p>code for creating labels on form</p>
  
  <pre><code>Public Class Form1
      Dim counter As Integer = 1
      Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  
  
          Dim lbl As New Label
  
          lbl.Name = "Label" &amp; counter
  
          lbl.Size = New Size(80, 20)
  
          lbl.Location = New Point(80, counter * 22)
  
          lbl.Text = TextBox1.Text
  
          AddHandler lbl.MouseMove, AddressOf obj1_MouseMove 'varocarbas
  
          Me.Controls.Add(lbl)
  
          counter += 1
  
      End Sub
  
  End Class
  </code></pre>
  
  <p>I want to drag created labels. Is that possible?</p>