I want to draw a string as an axis label. When I draw the string with following code, I can read it "from the left". The base line of the text is at the left side.
StringFormat format = CustomGraphics.StringFormat(ContentAlignment.MiddleCenter);
format.FormatFlags |= StringFormatFlags.DirectionVertical;
e.Graphics.DrawString(this.yAxis.Title.Text, this.yAxis.Title.Font,
textBrush, e.Bounds, format);
format.FormatFlags &= ~StringFormatFlags.DirectionVertical;
I want 开发者_开发百科to draw vertical but turn the orientation by 180 degrees. How can I control this? Is there another method that I should use?
Use Graphics.RotateTransform() to get the string rotated the way you want it. You'll need TranslateTransform() and MeasureText() to get the start-point right.
How do I rotate a label in C#? contains a long and powerful paint method, based originally on http://www.codeproject.com/KB/miscctrl/customtext.aspx
精彩评论