博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
GDI+ 绘制多行文本,自动换行。
阅读量:7165 次
发布时间:2019-06-29

本文共 660 字,大约阅读时间需要 2 分钟。

1,主要利用MessageString()这个函数来实现自动换行。截图如下:

 

代码如下:

ExpandedBlockStart.gif
View Code
  
//
绘制有边框的字体,并自动换行
        
private
 
void
 Form1_Paint(
object
 sender, PaintEventArgs e)
        {
            Graphics g 
=
 e.Graphics;
            Font f 
=
 
new
 Font(
"
Aris
"
15
, FontStyle.Italic 
|
 FontStyle.Strikeout);
            
string
 s 
=
 
"
this is my name ,and what about you ,ok no problems,every is ok,something is goods,program.cs ,I want to make susccfjdkjk,grapeBunch/bmp
"
;
            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);
         
            
        }

 

 

转载于:https://www.cnblogs.com/85538649/archive/2011/08/02/2124488.html

你可能感兴趣的文章