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

GDI+ 绘制多行文本,自动换行。

 

代码如下:

  //绘制有边框的字体,并自动换行
        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(2020, sf.Width, sf.Height);
            g.DrawRectangle(Pens.Red,rf.Left,rf.Top,rf.Width,rf.Height);
            g.DrawString(s,f,Brushes.Black,rf);
         
            
        }

相关文章:

  • 2021-06-25
  • 2021-10-12
  • 2021-12-17
  • 2021-06-08
  • 2021-09-01
  • 2022-12-23
猜你喜欢
  • 2021-06-04
  • 2022-01-11
  • 2022-12-23
  • 2022-02-16
  • 2021-11-30
  • 2021-06-19
  • 2022-12-23
相关资源
相似解决方案