Expand|Select|Wrap|Line Numbers
- InitializeComponent();
- this.panel2.DragOver += new DragEventHandler(panel2_DragOver);
- this.panel2.DragDrop += new DragEventHandler(panel2_DragDrop);
- panel2.AllowDrop = true;
- panel1.AllowDrop = true;
- foreach (Control ctrl in this.panel1.Controls)
- {
- ctrl.MouseDown += new MouseEventHandler(button1_MouseDown);
- }
- foreach (Control ctrl1 in this.panel2.Controls)
- {
- ctrl1.MouseDown += new MouseEventHandler(button1_MouseDown);
- }
- }
- private void button1_MouseDown(object sender, MouseEventArgs e)
- {
- Control ctrl1 = sender as Control;
- ctrl1.DoDragDrop(ctrl1, DragDropEffects.Copy);
- }
- private void panel2_DragDrop(object sender, DragEventArgs e)
- {
- Control ctrl = e.Data.GetData(e.Data.GetFormats()[0]) as Control;
- if (ctrl != null)
- {
- ctrl.Location = this.panel2.PointToClient(new Point(e.X, e.Y));
- this.panel2.Controls.Add(ctrl);
- }
- // panel2.BackColor = Color.Aquamarine;
- }
- private void panel1_DragDrop(object sender, DragEventArgs e)
- {
- Control ctrl1 = e.Data.GetData(e.Data.GetFormats()[0]) as Control;
- if (ctrl1 != null)
- {
- ctrl1.Location = this.panel1.PointToClient(new Point(e.X, e.Y));
- this.panel1.Controls.Add(ctrl1);
- }
- // panel1.BackColor = Color.DarkMagenta;
- }
- private void panel2_DragOver(object sender, DragEventArgs e)
- {
- e.Effect = DragDropEffects.Copy;
- }
- private void panel1_DragOver(object sender, DragEventArgs e)
- {
- e.Effect = DragDropEffects.Copy;
- }