2011-03-20 33 views
1

我想繪製一個字符串作爲軸標籤。當我用以下代碼繪製字符串時,我可以從「左側」讀取它。文本的底線在左側。如何控制Drawstring的方向?

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; 

我想繪製垂直,但將方向轉180度。我怎樣才能控制這個?我應該使用另一種方法嗎?

回答

2

使用Graphics.RotateTransform()獲取字符串以您想要的方式旋轉。您需要TranslateTransform()和MeasureText()才能獲得正確的起點。

相關問題