I have a array of pictureboxes like this:
PictureBox[] pb = new PictureBox[71]
{
pictureBox1,pictureBox2,pictureBox3,...etc
};
and I know how to assign a event to a single object,
private void pictureBox1_MouseHover(object sender, EventArgs e)
{
pictureBox1.BackColor = Color.Red;
}
but how can I assign this array to 1 event handler, the final result should be when I’m hovering 1 of the 71 boxes the .backColor property, instead of making 71 handlers for each picturebox.
Subscribe the event handlers like so:
And set the
BackColorlike so:senderis the actual PictureBox that fired the event.