我在MSDN上看的,FONT类的用法:有段代码稍加改造就完成了一个意想不到的效果:
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
MPaint (e);
return;
}
private void MPaint(PaintEventArgs e)
{
float m = 3.0f;
// Create a Font object.
Font myFont = new Font("Arial", 16);
//Draw text to the screen with myFont.
e.Graphics.DrawString(
"This is the first line",
myFont,
Brushes.Yellow ,
new PointF(0, 0));
//Get the height of myFont.
float height = myFont.GetHeight(m);
//Draw text immediately below the first line of text.
e.Graphics.DrawString(
"This is the first line",
myFont,
Brushes.Red ,
new PointF(0, height));
}
效果如下图: