Conversion between a colour and a brush

rbulph

Well-known member
Joined
Feb 17, 2003
Messages
343
Given a brush, how do you get its colour? And vice versa - given a colour, how can you get a brush with that colour?
 
Brushes and colours

There are various kinds of brushes, and only the SolidBrush has a specific colour. Test if your brush is a SolidBrush, then cast it to a SolidBrush and access its Color member. Similarly, you can turn a colour into a brush by creating a new SolidBrush based on it:

C#:
Brush br = new SolidBrush(col);

col = (br as SolidBrush).Color;

Good luck :cool:
 
Back
Top