winform 鼠标拖动移动图片位置

编程入门 行业动态 更新时间:2024-10-18 03:34:37

winform <a href=https://www.elefans.com/category/jswz/34/1769042.html style=鼠标拖动移动图片位置"/>

winform 鼠标拖动移动图片位置

  • 三个事件,与图片的控件容器绑定、即可实现鼠标拖动移动图片位置
        private void pbMain_MouseDown(object sender, MouseEventArgs e){photo_rec = photo_show1.GetPictureBoxZoomSize(pictureBox1);pt = Cursor.Position;this.Cursor = Cursors.SizeAll;}private void pbMain_MouseUp(object sender, MouseEventArgs e){this.Cursor = Cursors.Default;int px = Cursor.Position.X - pt.X;int py = Cursor.Position.Y - pt.Y;}private void pbMain_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;}}

更多推荐

winform 鼠标拖动移动图片位置

本文发布于:2023-07-03 20:07:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1011290.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:鼠标   拖动   位置   图片   winform

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!