Click here to Skip to main content
15,893,486 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Friends,

I am using Flowlayout panel in c# to display list of images dynamically.
Images are displaying as well.
Images count may vary, which is known only on run time.

Here is what I want.....

1) Need to know, in Flowlayout panel, which image is clicked by the user?
2) Then need to read the file name of selected image file.

Please help me ASAP.

Thanks in advance.
Posted

1 solution

Hi,

I think this might solve your problem:

C#
foreach (var item in this.flowLayoutPanel1.Controls)
{
    ((PictureBox)item).Click += (sender, e) =>
        {
            // read the file name
            string location = ((PictureBox)sender).ImageLocation;

            MessageBox.Show(string.Format("Child Control Names: {0} - Image Location: {1}", ((PictureBox)sender).Name, location));
        };
}


Kind regards,
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900