Originally posted by KrazyKandy
Hello, I had someone from here help me call pictureboxes with images from my resources, but I want each picturebox to have its own click and do something different. Can anyone help me?
You must login or register to view this content.
I made a thread about something like this a few years ago in VB.NET
You can refer to it here:
You must login or register to view this content.
What you want to look for is the AddHandler since you want to add functionality to the the controls. C# isn't exactly the same since it doesn't have addhandler but you get the idea. For instance for your picture box:
Images[i].Click += new EventHandler(pictureBox_Click);
void pictureBox_Click(object sender, EventArgs e)
{
//Do Stuff
}
The above code will add that event to every picture box. If you need each one to do something different then you would test for the specific picture box in pictureBox_Click