c# button drag and drop

  1. namespace xxx
  2. {  
  3.     public partial class Form1 : Form  
  4.     {  
  5.         Point p;  
  6.         public Form1()  
  7.         {  
  8.             InitializeComponent();  
  9.         }  
  10.   
  11.         privatevoid button1_MouseDown(object sender, MouseEventArgs e)   
  12.         {  
  13.             p = e.Location;  
  14.         }  
  15.   
  16.         privatevoid button1_MouseUp(object sender, MouseEventArgs e)   
  17.         {  
  18.             p = e.Location;  
  19.         }  
  20.   
  21.         privatevoid button1_MouseMove(object sender, MouseEventArgs e)   
  22.         {  
  23.             if (e.Button == System.Windows.Forms.MouseButtons.Left)  
  24.               \\this.button1.Location = new Point(this.button1.Left + (e.X - p.X), this.button1.Top + (e.Y - p.Y));  
  25.               bool buttonToImgbox();
  26.         }  
  27.     }  
  28. }  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324811686&siteId=291194637