5.C#编程学习——窗体字体文本

96 阅读1分钟

5.C#编程学习——窗体字体文本

源码

usingSystem;

usingSystem.Drawing;

usingSystem.Windows.Forms;

 

classPaintHello

{

    publicstaticvoid Main()

    {

        Form form = newForm();

        form.Text = "Paint Hello";

        form.BackColor = Color.White;

        form.Paint += newPaintEventHandler(MyPaintHandler);

 

        Application.Run(form);

    }

    staticvoid MyPaintHandler(object objSender, PaintEventArgs pea)

    {

        Form form = (Form)objSender;

        Graphics grfx = pea.Graphics;

 

        grfx.DrawString("Hello, world!", form.Font, Brushes.Black, 0, 0);

    }

}

通过DrawString函数来实现文本描述。