c# winform 绘制多行文本:自动换行:文本

源码地址:https://download.csdn.net/download/wojiuguowei/85826419

class Class1 : PictureBox
{
    public Class1()
    {
        //this.BackColor = Color.Blue;
    }


    protected override void OnPaint(PaintEventArgs e)
    {
        Graphics g = e.Graphics;

        //g.FillRectangle(Brushes.White, ClientRectangle);


        // Draw multiline text
        Font trFont = new Font("Times New Roman", 12);
        Rectangle rect = new Rectangle(40, 40, this.Width -80, this.Height - 80);
        g.DrawRectangle(Pens.Blue, rect);
        String longString = "Text Text Text Text Text Text Text Text Text Text ttttttttttttttttttttttttttttttt ";
        g.DrawString(longString, trFont, Brushes.Black, rect);

    }
}

参考地址:http://www.java2s.com/Code/CSharp/2D-Graphics/Drawmultilinetextautowrap.htm

你可能感兴趣的:(c#,#,绘图,多行,自动换行)