Advertisement
2_2002-2004 Miscellaneous #122884

Move controls in a form

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

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
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

Because it is better to program than to read, download the code and take a look at it.
You can also read the instructions.htm file if you like to read.
If you need help, drop me a line...
Upload
Original Comments (3)
Recovered from Wayback Machine