C#如何在WINDOWS APP窗口中移动图片?
C#如何在WINDOWSAPP窗口中移动图片?具体意思是,如何让一个图片在C#的窗口上移动,请回答得详细一些,先谢谢各位!...
C#如何在WINDOWS APP窗口中移动图片?
具体意思是,如何让一个图片在C#的窗口上移动,请回答得详细一些,先谢谢各位! 展开
具体意思是,如何让一个图片在C#的窗口上移动,请回答得详细一些,先谢谢各位! 展开
3个回答
展开全部
左键点住图片拖动:
Point pt;
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
pt = Cursor.Position;
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
int px = Cursor.Position.X - pt.X;
int py = Cursor.Position.Y - pt.Y;
pictureBox1.Location = new Point(pictureBox1.Location.X + px, pictureBox1.Location.Y + py);
pt = Cursor.Position;
}
}
Point pt;
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
pt = Cursor.Position;
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
int px = Cursor.Position.X - pt.X;
int py = Cursor.Position.Y - pt.Y;
pictureBox1.Location = new Point(pictureBox1.Location.X + px, pictureBox1.Location.Y + py);
pt = Cursor.Position;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询