protected override void OnPaint(PaintEventArgs pea)
{
Graphics gpis = pea.Graphics;
gp = gpis;
//gpis.DrawString("haha", new Font(this.Font, FontStyle.Regular),new SolidBrush(Color.Coral), new PointF(2, 3));
StringFormat sf = new StringFormat();//格式文本
sf.Alignment = StringAlignment.Center;//alignment属性垂直
sf.LineAlignment = StringAlignment.Center;//水平
sf1 = sf;
sz.Width=this.ClientSize.Width / 2;
sz.Height =this.ClientSize.Height / 2;
//了解学习drawstring方法不同重写,如下为在窗体(严格叫客户区中间显示对应文字) clientsize为客户区大小
gpis.DrawString("在窗体中显示的格式化文字", new Font(this.Font, FontStyle.Regular), new SolidBrush(Color.Brown), this.ClientSize.Width / 2, this.ClientSize.Height / 2, sf);
}
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9240380/viewspace-734955/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/9240380/viewspace-734955/