I created a control (called Table) made up by two pictureBoxes and two Labels.
I'm trying to drag and drop it from a panel to another, but it doesn't work. This is my code:
void TableExampleMouseDown(object sender, MouseEventArgs e)
{
tableExample.DoDragDrop(tableExample, DragDropEffects.Copy);
}
void Panel2DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.Copy;
}
void Panel2DragDrop(object sender, DragEventArgs e)
{
panel2.Controls.Add((Table) e.Data.GetData(e.Data.GetFormats()[0]));
}
Obviously I've set AllowDrop to true in panel2. Already when I click on Table object (which is in panel1), the mouse cursor doesn't change. It looks like the MouseDown event doesn't fire...
Thank you!
This is the part of the constructor code in which I subscribe Handlers:
this.tableExample.MouseDown += new System.Windows.Forms.MouseEventHandler(this.TableExampleMouseDown);
this.label2.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Label2MouseDown);
this.panel1.DragDrop += new System.Windows.Forms.DragEventHandler(this.Panel1DragDrop);
this.panel1.DragEnter += new System.Windows.Forms.DragEventHandler(this.Panel1DragEnter);