Tools Links Login

Move controls in a form

Use this code to drag and drop (almost) any control anywhere on a form.

Original Author: Michael Klinteberg

Assumptions

Add some controls and a checkBox Named chkOnOff

API Declarations

Option Explicit

Code

Private Sub chkOnOff_Click()
On Error Resume Next 'resume next beacuse not all controls support dragmode
Dim ctl As Control
'Turn dragmode on/off

If chkOnOff.Value Then
  For Each ctl In Me.Controls
   'Debug.Print TypeName(ctl)
   ctl.DragMode = vbAutomatic
  Next
Else
  For Each ctl In Me.Controls
   'Debug.Print TypeName(ctl)
   ctl.DragMode = vbManual
  Next
End If
Me.chkOnOff.DragMode = vbManual
End Sub
Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
'Move the control
Source.Top = Y
Source.Left = X
End Sub

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 87 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.