Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to subclass control?
Message
 
 
To
17/02/2007 00:43:23
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01184867
Message ID:
01317036
Views:
11
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
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform