using System.Drawing; using System.Windows.Forms; //... protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Graphics g = e.Graphics; Pen bluePen = new Pen(Color.Blue, 3); g.DrawRectangle(bluePen, new Rectangle(50, 50, 100, 100)); }
using System.Drawing; using System.Windows.Forms; //... protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Graphics g = e.Graphics; Brush redBrush = new SolidBrush(Color.Red); g.FillRectangle(redBrush, new Rectangle(50, 50, 100, 100)); }The package library for the Graphics class is located in System.Drawing.dll.