Reputation: 856
I have 2 forms.
When pressing a button in form1, form2 shows up. What I want is pressing a button in form2 draws a rectangle on to form1 picturebox.
I Wrote an event handler function for button clicked in Form2 to be handled in Form1, but in handler I can't draw anything in form1's picturebox.
How can I achieve it?
Upvotes: 2
Views: 863
Reputation: 81620
In your event code on Form1 where you are receiving the button click event from Form2, try this:
using (Graphics g = Graphics.FromImage(pictureBox1.Image))
g.FillRectangle(Brushes.Red, new Rectangle(10, 10, 32, 32));
pictureBox1.Invalidate();
Upvotes: 3