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.
CodePudding user response:
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