string text = "Hello, World!"; Font font = new Font("Arial", 12, FontStyle.Bold); SolidBrush brush = new SolidBrush(Color.Black); Graphics graphics = CreateGraphics(); graphics.DrawString(text, font, brush, new PointF(10, 10));
private void Form1_Paint(object sender, PaintEventArgs e) { string text = "Windows Forms"; Font font = new Font("Times New Roman", 16, FontStyle.Regular); SolidBrush brush = new SolidBrush(Color.Blue); e.Graphics.DrawString(text, font, brush, new PointF(50, 50)); }This example shows how to draw the text "Windows Forms" with font Times New Roman, size 16, and regular style on a Windows Form using a blue color brush. The Microsoft DrawString method is a part of the System.Drawing namespace in the .NET Framework.