-1

I want to use an RGB color instead of default color of C#, but I have no idea how.

e.Graphics.DrawString("Order Summary",
    new Font("Roboto", 15, FontStyle.Bold),
    Brushes.SteelBlue, new Point(350, 20));
Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
xeyon
  • 27
  • 4
  • 1
    Well, you're currently using `Brushes.SteelBlue`. Have you looked into how you might create a `Brush` for the color you want? – Jon Skeet Nov 22 '22 at 15:31
  • I just looked into it and got a solution thank you. I didn't know it was this easy. Brush brush = new SolidBrush(Color.FromArgb(77, 183, 255)); e.Graphics.DrawString("Order Summary", new Font("Roboto", 15, FontStyle.Bold), brush, new Point(350, 20)); – xeyon Nov 22 '22 at 15:36
  • I'd strongly advise you to "just look into it" *before* asking a question in future. It's worth asking yourself whether there was anything unclear in terms of where the color was coming from in the code you'd already got, and whether there was anything stopping you from taking the next step *without* someone else helping. – Jon Skeet Nov 22 '22 at 15:40
  • Do not forget to dispose fonts and brushes which did you create – Selvin Nov 22 '22 at 15:44

1 Answers1

4

Try this:

e.Graphics.DrawString("Order Summary", new Font("Roboto", 15, FontStyle.Bold), new SolidBrush(Color.FromArgb(100, 100, 100, 100)), new Point(350, 20));

You could also do something like this, if you don not want to specify the RGB values:

e.Graphics.DrawString("Order Summary", new Font("Roboto", 15, FontStyle.Bold), new SolidBrush(Color.Blue), new Point(350, 20));
Jonathan Barraone
  • 489
  • 1
  • 3
  • 20