17-10-12, 05:54 PM
كاتب الموضوع : Boutemine Oualid
السلام عليكم و رحمة الله وبركاتهC#
كود :
Point start = new Point();
private void panel_MouseMove( object sender, MouseEventArgs e )
{
Panel p = sender as Panel;
if ( e.Button == MouseButtons.Left )
{
Point mousePos = this.PointToClient( Control.MousePosition );
if ( start.IsEmpty )
start = new Point( mousePos.X - p.Left, mousePos.Y - p.Top );
p.Location = new Point( mousePos.X - start.X, mousePos.Y - start.Y );
}
else if ( !start.IsEmpty )
start = new Point();
}
كود :
Private start As New Point()
Private Sub panel_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles Me.panel.MouseMove
Dim p As Panel = sender
If e.Button = MouseButtons.Left Then
Dim mousePos As Point = Me.PointToClient(Control.MousePosition)
If start.IsEmpty Then start = New Point(mousePos.X - p.Left, mousePos.Y - p.Top) p.Location =
New Point(mousePos.X - start.X, mousePos.Y - start.Y)
ElseIf Not start.IsEmpty Then
start = New Point()
End If
End Sub