Adding a mouse click eventhandler to a PictureBox
c#, winforms
Solution
Just add an event handler using the `+=` operator:
picOneFaceUpA.MouseClick += new MouseEventHandler(your_event_handler);
Or:
picOneFaceUpA.MouseClick += new MouseEventHandler((o, a) => code here);
Problem
I have a picturebox control and upon clicking it another PictureBox appears at a specific location. I.o.w it wasnt added from the toolbox. ``` PictureBox picOneFaceUpA = new PictureBox(); picOneFaceUpA.Location = new Point(42, 202); picOneFaceUpA.Width = 90; picOneFaceUpA.Height = 120; picOneFaceUpA.Image = Image.FromFile("../../Resources/" + picFaceUpToBeMoved[0] + ".png"); Controls.Add(picOneFaceUpA); picOneFaceUpA.BringToFront(); ``` How would I add a MouseClick eventhandler to this control? Thanks