最好使用 Graphics
对象,如何绘制字符串以使字符仍然正常定向,但垂直堆叠?
最佳答案
只需将字符串拆分为字符并绘制每个字符,将字体的行高添加到 Y 轴变量:
protected override void OnPaint(PaintEventArgs e)
{
float x = 10.0F;
float y = 10.0F;
string drawString = "123";
using(SolidBrush brush = new SolidBrush(Color.Black))
using (Font drawFont = new Font("Arial", 16))
{
foreach (char c in drawString.ToCharArray())
{
PointF p = new PointF(x, y);
e.Graphics.DrawString(c.ToString(), drawFont, brush, p);
y += drawFont.Height;
}
}
base.OnPaint(e);
}
关于c# - 在 WinForms 中绘制垂直堆叠的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1521157/