zoukankan      html  css  js  c++  java
  • csharp中实现图片拖拽

    基于Csharp的属性、动作,添加相关委托操作,实现图相框的拖拽。
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            private void Form1_Load(object sender, EventArgs e)
            {
                pictureBox1.AllowDrop = true;
                pictureBox2.AllowDrop = true;
                pictureBox3.AllowDrop = true;
                pictureBox1.MouseMove += SenderPB_MouseMove;
                pictureBox3.MouseMove += SenderPB_MouseMove;
            }
            private void SenderPB_MouseMove(object sender, MouseEventArgs e)
            {
                PictureBox thisPB = (PictureBox)sender;
                if ((e.Button & MouseButtons.Left) == MouseButtons.Left && (thisPB.Image != null))
                {
                    Bitmap b = new Bitmap(thisPB.Image);
                    DragDropEffects eff = ((PictureBox)sender).DoDragDrop(b, DragDropEffects.Copy);
                }
            }
            private void pictureBox2_DragEnter(object sender, DragEventArgs e)
            {
                e.Effect = DragDropEffects.Copy;
            }
            private void pictureBox2_DragDrop(object sender, DragEventArgs e)
            {
                if (e.Data.GetDataPresent(typeof(Bitmap)))
                {
                    this.pictureBox2.Image = (Bitmap)e.Data.GetData(typeof(Bitmap));
                }
            }
        }




    附件列表

      目前方向:图像处理,人工智能
    • 相关阅读:
      Java回顾之Spring基础
      Java回顾之ORM框架
      Java回顾之JDBC
      Java回顾之一些基础概念
      Java回顾之反射
      Java回顾之序列化
      platform_device与platform_driver
      DB9 公头母头引脚定义及连接
      浅谈UML的概念和模型之UML九种图
      为Windows 7的winsxs目录瘦身,谨慎。
    • 原文地址:https://www.cnblogs.com/jsxyhelu/p/14682452.html
    Copyright © 2011-2022 走看看