0

How to Convert from 'System.Drawing.Color' to 'System.Drawing.Brush' ?

This cast does not work.

(Brush)colorDialog1.Color;

I have a color dialog, and I need to pick the color from it and use as Brush color

Romo Daneghyan
  • 2,099
  • 3
  • 18
  • 23

1 Answers1

1

You have to choose a specific type of Brush, most common is SolidBrush:

using (Brush brush = new SolidBrush(colorDialog1.Color))
{
    // perform operations
}

See http://msdn.microsoft.com/en-us/library/aa983677(v=vs.71).aspx for a list of available brushes.

C.Evenhuis
  • 25,996
  • 2
  • 58
  • 72