Angel.Net 0 Newbie Poster

Hello, I need some help conserning drag and drop operation of a picture box(es)!

So I have two panels. One of them contains buttons, when we click on a button I am creating a PictureBox directly into the second panel which will be my working plot! The idea is that I should have the possibility to add multiple pictures and to connect them in a kind of a graf/tree and then do some actions!
So the picture is loaded in the created picture box into the Working Panel and from now on I cannot drag and place it in a position I want!
How I should do this?

The code:

 private void btnTransformerWireProtection_Click(object sender, EventArgs e)
 {
            base.OnLoad(e);
            countClick++;

            if (countClick <= 1)
            {
                PictureBox pbFirstPicture = new PictureBox();

                pbFirstPicture.Name = "TransformerWreProtection" + countClick;

                pbFirstPicture.Load("C:/Documents and Settings/Welkom/My Documents/Visual Studio 2008/Projects/GEEC/GEEC/Image/Source1-1.png");
                pbFirstPicture.BorderStyle = BorderStyle.FixedSingle;

                pbFirstPicture.SizeMode = PictureBoxSizeMode.AutoSize;
                pbFirstPicture.Location = new System.Drawing.Point(10, 10);
                Controls.Add(pbFirstPicture);
                this.pnlWorkingPlot.Controls.Add(pbFirstPicture);

                pbFirstPicture.MouseDown += new MouseEventHandler(pbFirstPicture_MouseDown);
                pbFirstPicture.Click += new EventHandler(pbFirstPicture_Click);
            }
            else {
                 //create other picture with different position on the panel
            }
 }

void pbFirstPicture_MouseDown(object sender, MouseEventArgs e)
        {

            if (sender is PictureBox && e.Button == MouseButtons.Left)
            {
                this.pbFirstPicture.AllowDrop = true; //the AllowDrop is not displayed by default!!!
                isDragging = true;
                dragOffsetX = e.X;
                dragOffsetY = e.Y;
            }
         }

private void pbFirstPicture_MouseMove(object sender, MouseEventArgs e)
        {
            if (isDragging)
            {
                PictureBox pb= (PictureBox)sender;

                pb.BringToFront();
                pb.Top += (e.Y - dragOffsetY);
                pb.Left += (e.X - dragOffsetX);
            }
         }

Where something is not done good and how I can make it working for my case?

Thnak you very much in advanced for your time and help!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.