Getting Control From FlowLayoutPanel

Hi,
I have added no.of images(pictureboxes) in a flowlayoutpanel using openfiledialog.
Now i want to remove the particular control at runtime but i am able to get the particular control.
How can i name the pictureboxes while adding them in flowlayoutcontrol and after adding them how can i get the particular control by either selecting by mouseclick or anything else.
Can i select the added control by mouseclick.

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:

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?

My apologies sir... That code works fine. I had my form and panel sized so small I didn't notice it was filling that location with next picture... :$ One of those moments for me I suppose....

Thanks To All,
The all given code works perfectly, and now i am able to name as well as remove the pictureboxes which i want.

Now, I want the name of the image which i add in flowlayout must get displayed along with that picturebox. For that purpose i have added label before adding picturebox which contain the name of the image.

But, now when i remove the picturebox, the label with the name get remained in the flowlayout. As i don't click on that label how can i delete that label.

if the picturebox name is pic0, then label of that picturebox name will be lblName0.

So, is there anything so that i can delete the label which matches the combination (pic0,lblName0 -pic1,lblName1).

Glad the code helped you both. DdoubleD, no apology needed, we all have THOSE moments :p

And to Vidya, heres a revised version to add and remove a matching label. This method works if pic0 has a label named lbl0. There may be a better way to associate a label and a picture, i'll have a play around when i get 5 mins, but this should get you moving in the right direction.

Am i right in thinking this is a classroom exercise? If so, and you're new to C#, please remember to examine the code to make sure you understand it. If you just use it without understanding it you wont be able to apply the principles later :)

The all pictureboxes which i have added in flowlayoutpanel, now i use to add those images path in database, i have did that all and along with adding in database i also have to copy those images to particular location suppose "D:\DataImages".

If the folder contain that image already then i use to delete that image and again add it to the same location..

This all works fine when the images/pictureboxes lodaded for first time in the flowlayoutpanel, but if the image is added in the flowlayoutpanel and we try to delete that image it shows error

"The file is used by another process" and i am not able to delete it, but before deleting those images i clear all controls from flowlayoutpanel, but still the error occurs... Can you help me on that...