>Is there anything that prevent me from using System.Drawing.Brush as a property in a custom control?
>
>private System.Drawing.Brush _LightBrush;
>public System.Drawing.Brush LightBrush
>{
> get{return _LightBrush;}
> set{_LightBrush = value;}
>}
>
>then in the OnPaint() event I use the brush to fill a region.
>
>I do not receive a compile time error but I do catch an exception at run time (it is an ArgumentNullException stating that value can not be null). I would like to change the property to a different value in the designer but I can't because it is disabled ("grayed out").
>
>I would like the user of my control (that would be me) to be able to select the brush color at design time in the property sheet.
>
>I tried making the property of type System.Drawing.Color and then try to somehow declare a brush with that color in the OnPaint() event, but I am kind of stuck on that one.
>
>Also something that might help me if I could remember how to assign a default value to a property.
>
>Any help would be appreciated.
>
>Thanks,
>Einar
>
>UPDATE:
>Using DefaultValue:
>
>DefaultValue(System.Drawing.Brushes.Cyan)
>
>Gives me the following compile time error:
>
>An attribute argument must be a constant expression, typeof expression or array creation expression.
>
>System.Drawing.Brushes.Cyan seems pretty darn constant to me.
Einar,
I'm not exactly sure but trying anyway:) Brush is an abstract class that can't be instantiated. Might that be the problem and you should instead say use SolidBrush.
Cetin