using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace Project02 { public partial class Hw2 : Form { private bool _btnclickme1 = false; public Hw2() { InitializeComponent(); } private void btn1_Click(object sender, EventArgs e) { _btnclickme1 = true; pbx1.Invalidate(); } private void pbx1_Paint(object sender, PaintEventArgs e) { Graphics paper; paper = pbx1.CreateGraphics(); Pen sharpie = new Pen(Color.Black); if (_btnclickme1) { paper.DrawRectangle(sharpie, 10, 10, 100, 100); } } } }