How can the user move a panel on a form with the cursor
I have a form which has a panel on it. This form is a child of an MDI form. The panel is scrollable by the user with scroll bars and working well at this point. I would like to know if there is any way this could be modified so that the user could drag the panel with the cursor
as well? If so, can you supply the correct event and code?
Alexandru LazarPosted Aug 3, 2010, 3:51 AM
Rob CroPosted Aug 2, 2010, 8:15 PM
Sam HobbsPosted Aug 2, 2010, 1:53 PM
Alexandru LazarPosted Aug 2, 2010, 11:14 AM
private void panel1_MouseDown(object sender, MouseEventArgs e){
xDistance = panel1.Location.X - e.X;
yDistance = panel1.Location.Y - e.Y;
panelIsGrabbed = true;
}private void panel1_MouseMove(object sender, MouseEventArgs e)
{
if (panelIsGrabbed)
{
panel1.Location = new Point(e.X + xDistance, e.Y + yDistance);
}
}