problem with drag and drop for the winform using c#
Posted
by karthik
on Stack Overflow
See other posts from Stack Overflow
or by karthik
Published on 2010-04-19T02:53:12Z
Indexed on
2010/04/19
3:03 UTC
Read the original article
Hit count: 252
c#
I dont have the title bar in my winform, so i need to code drag and drop for the entire form. I am using the below code to do it, which works fine. I have two panels in my form, PanelA and PanelB. During the startup i show PanelA where the drag and drop works perfectly. Later when the user clicks the button in PannelA, i need to make PanelA visible false and show the PanelB My drag and drop is not working when the PanelB is loaded in form. Whats the problem here ?
private void SerialPortScanner_MouseUp(object sender, MouseEventArgs e) { this.drag = false; }
private void SerialPortScanner_MouseDown(object sender, MouseEventArgs e)
{
this.drag = true;
this.start_point = new Point(e.X, e.Y);
}
private void SerialPortScanner_MouseMove(object sender, MouseEventArgs e)
{
if (this.drag)
{
Point p1 = new Point(e.X, e.Y);
Point p2 = this.PointToScreen(p1);
Point p3 = new Point(p2.X - this.start_point.X,
p2.Y - this.start_point.Y);
this.Location = p3;
}
}
© Stack Overflow or respective owner