DdoubleD 315 Posting Shark

Ryshad, that code looks good to me, but for some reason when I execute it (have only tried with one PictureBox added in the panel) the Remove(pic2remove) method in the picture_click() event doesn't seem to remove the control from the panel. I don't see why this wouldn't work and it relates to a similar post I made where you provided input as well... Any thoughts as to why this is?

Heres some code demonstrating how to name the control at creation and adding an event handler to its Click() event. I have used the click event to delete the control:

namespace WindowsApplication3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < 10; i++)
            {
                PictureBox pb = new PictureBox();
                pb.Image = Properties.Resources.pic1;
                pb.Name = "pic" + i.ToString();
                pb.Click += new EventHandler(picture_click);
                flowLayoutPanel1.Controls.Add(pb);
                
            }
        }

        void picture_click(object sender, EventArgs e)
        {
            PictureBox pic2remove = (PictureBox)sender;
            flowLayoutPanel1.Controls.Remove(pic2remove);
        }
    }
}
DdoubleD 315 Posting Shark

I figured out my problem. I had included the database file in the project. Therefore it was overwritten each time I compiled the project, making it look like the database wasn't being updated. I created an external database and it works flawlessly now.
Thanks for the responses.

hi how did you do it?=) cause I'm using microsoft access to store the data and i was wondering how can i make the the database to be updated?

If including the Access database with the project, there is a property you can set for this in the project that prevents compiles from overwriting your updated database. Just select the .mdb in the project (Solution Explorer), and change the Copy to Output Directory property to be "Copy if newer" option.

DdoubleD 315 Posting Shark

By the way this albahari guy and i know each other, i am going to translate one of his tutorials(threading) into Turkish, we already made the deal but he said he is going to renew the tutorial, so i am waiting for him to complete.

It truly is a small world!;)