Question

I am Working with Visual C#. When overlay a text on the Picture, How can I set the font color?

graphicsImage.DrawString(textBox1.Text,
new Font("Arial", 12, FontStyle.Bold)
SystemBrushes.WindowText, new Point(10, 210));        
Was it helpful?

Solution

try to use SolidBrush like this,you will get red font:

graphicsImage.DrawString(textBox1.Text, new Font("Arial", 12, FontStyle.Bold), new SolidBrush(Color.Red), new Point(10, 210));

OTHER TIPS

There's no Font Color property, instead you should use the right Brush. Do not forget disposing IDisposable, in your case:

  using (Brush brush = new SolidBrush(Color.Red)) { // <- Let your text be red
    using (Font font = new Font("Arial", 12, FontStyle.Bold)) {
      // Paint the text with selected
      //  font - Arial 12 Bold
      // brush - solid red
      graphicsImage.Graphics.DrawString(
        textBox1.Text,       // <- what (text)
        font,                // <- font
        brush,               // <- color
        new Point(10, 210)); // <- where
    }
  }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top