*记得更改下方Panel的属性
public partial class Form2 : Form { public Form2() { InitializeComponent(); } Button btn = null; private void button1_MouseDown(object sender, MouseEventArgs e) { } private void panel2_DragEnter(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(typeof(Button))) { e.Effect = DragDropEffects.Move; } (sender as Panel).BackgroundImage = Properties.Resources._1; } private void panel2_DragDrop(object sender, DragEventArgs e) { int x = (sender as Panel).Location.X + 2; int y = (sender as Panel).Location.Y + 2; btn = e.Data.GetData(typeof(Button)) as Button; // btn.Location = this.PointToClient(new Point(e.X - btn.Width / 2, e.Y - btn.Height / 2)); //btn.Location = this.PointToClient(new Point(x, y)); btn.Location = new Point(x, y); //MessageBox.Show(x.ToString()+":"+y.ToString()+""); (sender as Panel).BackgroundImage = null; } private void panel2_DragLeave(object sender, EventArgs e) { (sender as Panel).BackgroundImage = null; } private void panel2_MouseEnter(object sender, EventArgs e) { (sender as Panel).BackgroundImage = Properties.Resources._1; } private void panel2_MouseLeave(object sender, EventArgs e) { (sender as Panel).BackgroundImage = null; } private void Form2_Load(object sender, EventArgs e) { } private void button1_MouseMove(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { (sender as Button).DoDragDrop(sender as Button, DragDropEffects.Move); } } private void button5_Click_1(object sender, EventArgs e) { MessageBox.Show((sender as Button).Text); } private void panel10_DragEnter(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(typeof(Button))) { e.Effect = DragDropEffects.Move; } (sender as Panel).BackgroundImage = Properties.Resources._3; } private Button btn2 = null; private void panel10_DragDrop(object sender, DragEventArgs e) { int x = (sender as Panel).Location.X + 2; int y = (sender as Panel).Location.Y + 2; btn2 = e.Data.GetData(typeof(Button)) as Button; btn2.Location = new Point(x, y); (sender as Panel).BackgroundImage = null; } private void panel10_DragLeave(object sender, EventArgs e) { (sender as Panel).BackgroundImage = null; } private void panel10_MouseEnter(object sender, EventArgs e) { (sender as Panel).BackgroundImage = Properties.Resources._4; } private void panel10_MouseLeave(object sender, EventArgs e) { (sender as Panel).BackgroundImage = null; } private void btnkuGou_Click(object sender, EventArgs e) { Process p = new Process(); p.StartInfo.FileName = @"D:Program FilesKuGouKGMusicKuGou.exe"; p.Start(); } //private void button6_Click(object sender, EventArgs e) //{ // //D:Program FilesKuGouKGMusic // Process p = new Process(); // p.StartInfo.FileName = @"D:Program FilesKuGouKGMusicKuGou.exe"; // p.Start(); //} }