Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to subclass control?
Message
De
14/05/2008 22:34:12
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Divers
Thread ID:
01184867
Message ID:
01317206
Vues:
17
Hi Naomi,

>I looked at your code for the sample, but I'm wondering, what type of the Editor do we need to add to be able to pick up the color in the Designer?

You're talking about web stuff and I don't do web stuff, so I have no idea. Sorry. =0(

~~Bonnie




>Hi Bonnie,
>
>I'm thinking also to change this method
>
>
> protected override void OnRowCreated(GridViewRowEventArgs e)
>        {
>            base.OnRowCreated(e);
>            //Colors charts - see http://www.1netcentral.com/color-chart.html
>            string onmouseoverStyle = "this.style.backgroundColor='#0bf'"; // Deepskyblue
>
>            string onmouseoutStyle = "this.style.backgroundColor='@BackColor'";
>
>            string rowBackColor = String.Empty;
>
>            if (e.Row.RowType == DataControlRowType.DataRow)
>            {
>
>                if (e.Row.RowState == DataControlRowState.Alternate)
>
>                    rowBackColor = System.Drawing.ColorTranslator.ToHtml(this.AlternatingRowStyle.BackColor).ToString();
>
>                else rowBackColor = System.Drawing.ColorTranslator.ToHtml(this.RowStyle.BackColor).ToString();
>
>                e.Row.Attributes.Add("onmouseover", onmouseoverStyle);
>
>                e.Row.Attributes.Add("onmouseout", onmouseoutStyle.Replace("@BackColor", rowBackColor));
>
>            }
>        }
>
>To be able to pick up HighlightCurrentRecordColor property.
>
>I looked at your code for the sample, but I'm wondering, what type of the Editor do we need to add to be able to pick up the color in the Designer?
>
>Thanks in advance.
>
>>Holger,
>>
>>Here's the syntax for overriding properties and giving them the ability to be re-set to a Default in the Property Sheet:
>>
>>
>>public class MyTextBox : TextBox
>>{
>>    private string m_MyProperty;
>>
>>    public MyTextBox
>>    {
>>        this.m_MyProperty = "";
>>    }
>>
>>    [DefaultValue("")]
>>    public string MyProperty
>>    {
>>        get {return this.m_MyProperty;}
>>        set {this.m_MyProperty = value;}
>>    }
>>    [DefaultValue(typeof(Color), "Window")]
>>    public override Color BackColor
>>    {
>>        get {return base.BackColor;}
>>        set {base.BackColor = value;}
>>    }
>>    [DefaultValue(typeof(Color), "WindowText")]
>>    public override Color ForeColor
>>    {
>>        get {return base.ForeColor;}
>>        set {base.ForeColor= value;}
>>    }
>>}
>>
>>
>>Setting some of these properties doesn't always work as you would expect them to ... one that comes to mind is "Text" ... you may or may not have problems setting a default for that one, depending on which control you're sub-classing. Also, some properties aren't virtual and can't be overridden. For those properties, you can use "new" instead of "override".
>>
>>>And another question: Would the changes, made to these properties, appear in the formdesigner, if you drop the control there?
>>
>>Yes!!
>>
>>~~Bonnie
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform