tags:

views:

102

answers:

1

I want to drag and drop images in a panel and want to avoid overlap of images.The images are dragging from another panel and I want to build a layout from that images. I was able to drag and drop images to the panel and want to avoid overlap when dropped.

private void panel1_DragDrop(object sender, DragEventArgs e) { // this.Cursor = Cursors.SizeAll;

        Control c = e.Data.GetData(e.Data.GetFormats()[0]) as Control;
        if (c != null)
        {
            mycontrol = c;


              c.Location = this.panel1.PointToClient((new Point(e.X, e.Y)));

                this.panel1.Controls.Add(c);

        }  

    }

e.X and e.Y must not be lied on top of other controls in the panel.

How can I do that? Please give me a appropriate solution.

Thank you.