e.Graphics.FillRectangle(Brushes.White, e.ClipRectangle); Font f = new Font ("Arial", 10); // Move the origin to the middle of the window:
System.Drawing.Size sz = TextArea.Size;
Point Middle = new Point (sz.Width / 2, sz.Height / 2);
e.Graphics.TranslateTransform (Middle.X, Middle.Y);
// Apply all transforms.... e.Graphics.RotateTransform (_angle);
// Create a new StringFormat object to
StringFormat format = new StringFormat (StringFormatFlags.NoClip);
format.Alignment = StringAlignment.Center;
format.LineAlignment = StringAlignment.Center;
e.Graphics.DrawString ("A simple TextString ", f, Brushes.Black, 0, 0,
format);
System.Drawing.Size sz = TextArea.Size;
Point Middle = new Point (sz.Width / 2, sz.Height / 2);
e.Graphics.TranslateTransform (Middle.X, Middle.Y);
// Apply all transforms.... e.Graphics.RotateTransform (_angle);
// Create a new StringFormat object to
StringFormat format = new StringFormat (StringFormatFlags.NoClip);
format.Alignment = StringAlignment.Center;
format.LineAlignment = StringAlignment.Center;
e.Graphics.DrawString ("A simple TextString ", f, Brushes.Black, 0, 0,
format);
override.The StringFormat class provides one method of rotating text using the
StringFormatFlags.DirectionVertical enumeration member. The other is to use
a transform. The latter method enables you to rotate the text vertically in
either direction. ie. top to left or top to right.
//////////////////////////////////////
因为如果要用label和textbox,只有重写这两个控件的事件了。
如果在一个控件上画的话
可以将象限旋转90度,再重设回去(ResetTransform)
e.Graphics.RotateTransform (angle);