See
MSDN: Graphics.RotateTransform method[
^]
Basically, to rotate a rectangle by 20 degrees clockwise in your paint event:
e.Graphics.RotateTransform(20.0F);
e.Graphics.DrawRectangle(Pens.Red, new Rectangle(5, 5, 30, 40));
"thnx ..it worked...but if i want to execute this in the Timer_tick event .for every second a rotation happened .. is that possible..and How please ?? Thanx anyway"
Firstly, don't draw in your timer event. Instead, handle the Paint event for a Panel or the Form, and draw there. Then in your timer event, change the angle to want top draw at (in a class level variable) and use the Invalidate method on the Panel or Form.
private float rotateAngle = 0.0F;
private void timer1_Tick(object sender, EventArgs e)
{
rotateAngle += 5.0F;
if (rotateAngle > 360.0F)
{
rotateAngle = 0.0F;
}
MyPanelForDrawingRectanglesOn.Invalidate();
}
I would prefer to use a panel as the drawing won't then go beneath any other controls, but it is up to you...