Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Why not System.Drawing.Brush as property?
Message
Information générale
Forum:
ASP.NET
Catégorie:
Conception classe
Titre:
Why not System.Drawing.Brush as property?
Divers
Thread ID:
01023287
Message ID:
01023287
Vues:
69
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.
Semper ubi sub ubi.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform