Resize a Rectangle at runtime
I need to resize a Rectangle at runtime.
I draw the Retangle on the Form1_Paint(), but unable to resize itt..
Graphics graph = this.CreateGraphics();
Pen penCurrent = new Pen(Color.Red);
Rect = new Rectangle(300, 50, 150, 75);
graph.DrawRectangle(penCurrent, Rect);
need some help!
Mike GoldPosted May 28, 2007, 12:26 AM
for example:
OnPaint()
{
e.Graphics.DrawRectangle(30, 30, x, y);
}
Set x and y outside of the event handler and call invalidate on the form region
OnButtonPressed (object sender, EventArg e)
{
x = x+5;
y = y + 5;
Invalidate(29, 29, x+1, y+1); // force it to redraw
}