salve a tutti
come potete vedere nel codice sotto
ho bisogno di muovere un pulsante mentre gli faccio DRAG
con questo codcie, lo muovo solo al muose UP
mentre ho bisogno dim uoverlo mentre faccio il dragging
come posso fare?
per far funzionare il codice basta solo metter un pulsante : button4
e abilitare il form: allowdragging=true
codice:Dim drag As Boolean Private posizione As New Point Private Sub Form1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragEnter e.Effect = DragDropEffects.All End Sub Private Sub Form2_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove If drag = False Then Exit Sub Invalidate(False) Button4.Location = New Point(e.X, e.Y) drag = False End Sub Private Sub Form2_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp drag = False End Sub Private Sub nMouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) sender.DoDragDrop(sender.text, DragDropEffects.Move) End Sub Private Sub PulsanteMouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button4.MouseMove ' sender.Location = posizione drag = False 'Se non ho premuto pulsanti, esco If e.Button = MouseButtons.None Then Exit Sub ' 'Controllo contiene il controllo che sta per iniziare il ' trascinamento() Dim Controllo As Control = sender If e.X >= 0 And e.X < Button4.Width And e.Y >= 0 And e.Y < Button4.Height Then Exit Sub End If Button4.DoDragDrop(Controllo, DragDropEffects.Copy) drag = True End Sub

Rispondi quotando