今天因为要用到图片拖拉操作,所以简单的看了下,做了一个简单的demo,先来张效果图:像狗皮膏药一样的图片拖拉操作

     

code is simple:

像狗皮膏药一样的图片拖拉操作像狗皮膏药一样的图片拖拉操作Code
public partial class 图片拖放 : Form
    {
        
public 图片拖放()
        {
            InitializeComponent();
        }
        PictureBox pb 
= null;

        
private void 图片拖放_Load(object sender, EventArgs e)
        {
            panel1.AllowDrop 
= true;
        }

        
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {        
            
this.pictureBox1.DoDragDrop(this.pictureBox1.Image, DragDropEffects.Copy);
        }

        
private void panel1_DragEnter(object sender, DragEventArgs e)
        {
            e.Effect 
= DragDropEffects.Copy;
        }

        
private void panel1_DragDrop(object sender, DragEventArgs e)
        {
            pb 
= new PictureBox();
            pb.Image 
= (Image)e.Data.GetData(DataFormats.Bitmap);
            pb.Size 
= new Size(2624);
            pb.Location 
= new Point(e.X - 105 - Location.X, e.Y - 30 - Location.Y);
            
            
this.panel1.Controls.Add(pb);
        }
    }

 

 

转载于:https://www.cnblogs.com/chenzhou851025/archive/2008/09/09/1287913.html

相关文章:

  • 2022-01-01
  • 2022-12-23
  • 2021-09-10
  • 2022-12-23
  • 2022-12-23
  • 2022-01-14
  • 2022-01-22
  • 2021-05-24
猜你喜欢
  • 2021-10-03
  • 2022-02-09
  • 2021-10-06
  • 2022-01-17
  • 2021-05-31
  • 2021-12-17
相关资源
相似解决方案