Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is there a way to find a pictureBox from many

I have 9 Pictures Boxes. If I click one Box it should change the Label to something like :

label_selectedcar = "Selected Car : " + 'ImageName'

I did create the Same Click Event for all of the PictureBoxes.

private void SelectCar(object sender, MouseEventArgs e)
    {
        var pictureBox = (PictureBox)sender;
    }

How can i get the Image Name from the PictureBox that i clicked on. The Images all have the car name in it.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Form

>Solution :

You can store userdata in the PictureBox.Tag property then use it like this

private void pictureBox1_Click(object sender, EventArgs e)
{
    var pictureBox = (PictureBox)sender;

    MessageBox.Show(pictureBox.Tag.ToString());
}

You could store the "ImageName" inside the tag

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading