可通过
StringFormat
sF = new StringFormat(StringFormatFlags.DirectionVertical);
以及使用
g.DrawString(s, f, Brushes.Black, rf,
sF);
来绘制竖向文本
View Code
private
void
Form1_Paint(
object
sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Font f = new Font( " Aris " , 15 , FontStyle.Italic);
string s = " this is my name ,and what " ;
StringFormat sF = new StringFormat(StringFormatFlags.DirectionVertical);
SizeF sf = g.MeasureString(s, f, 100 );
RectangleF rf = new RectangleF( 20 , 20 , sf.Width, sf.Height);
g.DrawRectangle(Pens.Red, rf.Left, rf.Top, rf.Width, rf.Height);
g.DrawString(s, f, Brushes.Black, rf,sF);
}
{
Graphics g = e.Graphics;
Font f = new Font( " Aris " , 15 , FontStyle.Italic);
string s = " this is my name ,and what " ;
StringFormat sF = new StringFormat(StringFormatFlags.DirectionVertical);
SizeF sf = g.MeasureString(s, f, 100 );
RectangleF rf = new RectangleF( 20 , 20 , sf.Width, sf.Height);
g.DrawRectangle(Pens.Red, rf.Left, rf.Top, rf.Width, rf.Height);
g.DrawString(s, f, Brushes.Black, rf,sF);
}