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 Lazar12 reputationPosted Aug 2, 2010, 7:14 AM EDT
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); } }private void panel1_MouseUp(object sender, MouseEventArgs e) { panelIsGrabbed = false; }Sam HobbsRank #107 · 20.5K reputationPosted Aug 2, 2010, 9:53 AM EDT
Rob Cro3 reputationPosted Aug 2, 2010, 4:15 PM EDT
Alexandru Lazar12 reputationPosted Aug 2, 2010, 11:51 PM EDT