Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Subclassing a subclass
Message
De
07/10/2007 19:27:35
 
 
À
07/10/2007 11:52:36
Information générale
Forum:
ASP.NET
Catégorie:
Conception classe
Divers
Thread ID:
01256172
Message ID:
01259307
Vues:
18
Hi!

Do you have something that you can share with all of us there on UT?

e.g. A base class library with all the basic controls (TextBox, ComboBox etc) with the correct/required overrides etc.

Thanks

Sarosh

>
>So, here's how you avoid that:
>
>
>public class MyTextBox : System.Windows.Forms.TextBox
>{
>	public MyTextBox()
>	{
>		this.BackColor = Color.Firebrick; ;
>	}
>	[DefaultValue(typeof(System.Drawing.Color), "Firebrick")]
>	public override System.Drawing.Color BackColor
>	{
>		get { return base.BackColor; }
>		set { base.BackColor= value; }
>	}
>}
>
>With the DefaultValue attribute in place, when this TextBox is dropped on a design surface, the line of code:
>
>
>this.BackColor = Color.FireBrick;
>
>
>will *NOT* be generated. Without the DefaultValue attribute, it *WILL* be generated.
>
>~~Bonnie
>
>
>
>
>
>
>>Hi Bonnie,
>>
>>>No, this particular problem that you had with the .Text property of a control is kind of special and that's because the IDE sets it when you drop the control on a design surface. You wouldn't normally handle it this way for other properties. Normally, all you need to do is set it in the constructor.
>>
>>I understand now. Thanks for the explanation.
>>
>>Alan
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform