Advertisement
2002C Miscellaneous #10986

Move controls in a form

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

AI

ملخص الذكاء الاصطناعي: 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.

كود المصدر
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

Upload
التعليقات الأصلية (3)
مسترجع من Wayback Machine