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));
                }
            }
        }




    附件列表

      目前方向:图像处理,人工智能
    • 相关阅读:
      JavaScript类型转换
      JavaScript中的 typeof,null,和undefined
      JavaScript循环
      JavaScript条件语句
      JavaScript运算符
      JavaScript字符串
      JavaScript事件
      JavaScript对象,函数,作用域
      JavaScript基础
      数值数据的特征预处理
    • 原文地址:https://www.cnblogs.com/jsxyhelu/p/14682452.html
    Copyright © 2011-2022 走看看