Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I move a Label Control ?

Status
Not open for further replies.

Suwito

Programmer
Apr 24, 2001
16
0
0
ID
Anyone know how to move Label Control in a Form with use DragDrop method ?
I need anyone help.
 
Its vary easy,
first use the event form_dragdrop,
then if ur label is label1 put this code:

source.left = x
source.top = y

I think this should work.
 
Yes that works but make sure u set the labels drag to vb automatic.

 
Yes that works but the Label Control is move in irregular position.
I want it move like when i design a form.
 
O that is very easy,
instead of just source.left use source.left = x I think u can use:

source.left = x - (source.width/2)
source.top = y - (source.height/2)

regards,
Brad
 
Thank you for your attn., but that is still not working properly.
Anyone knows,pls
 
Here is some code that will allow you to click on a Label (or any other control for that matter) and then drag it to a new location.

Code:
Option Explicit

Private mblnDrag As Boolean

Private Sub Label1_MouseDown(Button As Integer, Shift As 
Integer, X As Single, Y As Single)
   mblnDrag = True
End Sub

Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
   If mblnDrag Then
      Label1.Top = Y + Label1.Top
      Label1.Left = X + Label1.Left
   End If
End Sub

Private Sub Label1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
   mblnDrag = False
End Sub


Hope this helps you out . . .
- Jeff Marler B-)
 
Yes it works for me too.
Thanks Marler.

Do you know how to make a control can sizeable ?
Just click (mousedown)in a corner and drag it like a form.

Regards,
Suwito
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top