19-07-21, 02:42 AM
(18-07-21, 08:09 PM)Mtaktak كتب : هذا الحل الذي كنت ابحث عنه
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Button1.Parent = Pnel1
Button1.Location = New Point(0, 0)
End Sub
شكرا ابو انس ...
اعمل فورم واعمل عليه Button , Panel
وال Button على الفورم مش في ال Panel
حاول تطبق الكود هذا وتعرف ايش قصدي
السلام عليكم
اسمحو لي بهذا الطرح
تحريك جل ادوات الفورم بالموس (سحب و افلات) فقط بتغيير اسم الادات المراد ازاحتها في المتغيرات في المثال التالي الذي وضعب به كود لازاحة الاداتين الازرار واليبل مهما كان عددها
بالكود التالي
PHP كود :
Public Class Form1
Dim Off As Point
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
WireButton(Me)
WireLabels(Me)
End Sub
Private Sub WireLabels(ByVal cont As Control)
For Each ctl As Control In cont.Controls
If TypeOf ctl Is Label Then
AddHandler ctl.MouseDown, AddressOf obj1_MouseDown
AddHandler ctl.MouseMove, AddressOf obj1_MouseMove
ElseIf ctl.HasChildren Then
WireLabels(ctl)
End If
Next
End Sub
Private Sub WireButton(ByVal cont As Control)
For Each ctl As Control In cont.Controls
If TypeOf ctl Is Button Then
AddHandler ctl.MouseDown, AddressOf obj1_MouseDown
AddHandler ctl.MouseMove, AddressOf obj1_MouseMove
ElseIf ctl.HasChildren Then
WireButton(ctl)
End If
Next
End Sub
Private Sub obj1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Off.X = MousePosition.X - sender.Left
Off.Y = MousePosition.Y - sender.Top
End Sub
Private Sub obj1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
If e.Button = MouseButtons.Left Then
sender.Left = MousePosition.X - Off.X
sender.Top = MousePosition.Y - Off.Y
End If
End Sub
End Class

