Hi.
I created a borderless form and a MenuStrip docked on top of it that has a close and a minimize button.
How can I change form location when I drag that MenuStrip control?
Thanks :-)
Change form location with draging a control
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.


FroglegRank #1,020 · 1.9K reputationPosted Feb 2, 2011, 8:53 PM EST
public partial class Form1 : Form
{
bool _mouseDown = false;
Point startPt;
public Form1()
{
InitializeComponent();
}
private void menuStrip1_MouseDown(object sender, MouseEventArgs e)
{
_mouseDown = true;
startPt = e.Location;
}
private void menuStrip1_MouseMove(object sender, MouseEventArgs e)
{
if (_mouseDown == true)
{
Point currentPos = PointToScreen(e.Location);
Location = new Point(currentPos.X - startPt.X, currentPos.Y - startPt.Y);
}
}
private void menuStrip1_MouseUp(object sender, MouseEventArgs e)
{
_mouseDown = false;
}
}
Majid KamaliRank #6,453 · 266 reputationPosted Feb 3, 2011, 2:45 AM EST
Suthish NairRank #92 · 22.8K reputationPosted Feb 3, 2011, 7:35 AM EST
good example..