ugp

ugp

  • NA
  • 11
  • 0

Adding a Rectangle object to a Panel

May 25 2007 10:46 AM
I was able to add a button/label to a Panel like this; this.panel1.Controls.Add(this.button1); this.panel1.Controls.Add(this.label11); Works..OK! But, what I need is to add a Rectangle object to a Panel. I draw a Rectangle object; Graphics graph = this.CreateGraphics(); Pen penCurrent = new Pen(Color.Red); Rectangle Rect = new Rectangle(300, 50, 150, 75); graph.DrawRectangle(penCurrent, Rect); But when i do like this; this.panel1.Controls.Add(this.Rect); it gives an ERROR! ----- Says; Controls.Add() , works only for System.Windows.Forms.Control and CanNOT work with System.Drawing.Rectangle ----- So how can i achive this; add a Rectangle object to a Panel

Answers (3)