Dragging the panel on the form
-
Here is the code. I hope it works for you.
private Point mousePos;
private Point panelPos;
private bool isDragging;private void panel1_MouseDown(object sender, MouseEventArgs e)
{
if(e.Button == MouseButtons.Left)
{
isDragging = true;
Cursor.Current = Cursors.Hand;
mousePos = panel1.PointToScreen(e.Location);
panelPos = panel1.Location;
}}
private void panel1_MouseUp(object sender, MouseEventArgs e)
{
if(isDragging)
{
isDragging = false;
Cursor.Current = Cursors.Default;
}
}private void panel1_MouseMove(object sender, MouseEventArgs e)
{
if (!isDragging) return;
Point point = panel1.PointToScreen(e.Location);
panel1.Left = panelPos.X + point.X - mousePos.X;
panel1.Top = panelPos.Y + point.Y - mousePos.Y;
} -
Here is the code. I hope it works for you.
private Point mousePos;
private Point panelPos;
private bool isDragging;private void panel1_MouseDown(object sender, MouseEventArgs e)
{
if(e.Button == MouseButtons.Left)
{
isDragging = true;
Cursor.Current = Cursors.Hand;
mousePos = panel1.PointToScreen(e.Location);
panelPos = panel1.Location;
}}
private void panel1_MouseUp(object sender, MouseEventArgs e)
{
if(isDragging)
{
isDragging = false;
Cursor.Current = Cursors.Default;
}
}private void panel1_MouseMove(object sender, MouseEventArgs e)
{
if (!isDragging) return;
Point point = panel1.PointToScreen(e.Location);
panel1.Left = panelPos.X + point.X - mousePos.X;
panel1.Top = panelPos.Y + point.Y - mousePos.Y;
}Thanks, but is there a problem or what?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
-
Thanks, but is there a problem or what?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
-
That's cool. How about you write a quick little beginner article on it. As simple as it is, some folks might find it helpful :-D
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
-
That's cool. How about you write a quick little beginner article on it. As simple as it is, some folks might find it helpful :-D
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
-
Ummm, you don't know what?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
-
Ummm, you don't know what?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
-
I don't know that I can write an article,because I'm working on a project for Infomatrix. How about you? I guess you're a Software Developer.
Furkan93 wrote:
How about you?
Could just add it to the never ending list to todo :rolleyes:
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham