Properties not persisting at design time.

Discussion in 'ASP .Net Building Controls' started by Steve Barker, Jan 22, 2004.

  1. Steve Barker

    Steve Barker Guest

    Guys

    Hope someone can help me! I'm having real problems getting properties I type against a control I have written at design time

    I have written a control by inheriting from the Button control. I am trying to add a feature whereby the control changes to a different color when the mouse floats over it, or when the button has the focus. The color changing works if the 'LightColor' is set at runtime in code. However, if I draw the control on a form at design time, change the 'LightColor' property in the Property viewing window, save the form, then close and reopen the form, the property value (as seen in the window) goes back to the default value for the control. It's driving me mad, since I can't see what I've done wrong.

    Here is the code for my control

    -------------------------------------------------------------------------------
    using System
    using System.Collections
    using System.ComponentModel
    using System.Drawing
    using System.Data
    using System.Windows.Forms

    namespace HCS.Components.Control

    public class LightButton : Butto

    #region Field

    private System.ComponentModel.Container components = null
    private Color mBackColor
    private Color mLightColor
    private bool mIsMouseOver

    #endregio

    #region Constructo

    public LightButton(

    // This call is required by the Windows.Forms Form Designer
    InitializeComponent()

    mBackColor = base.BackColor
    mLightColor = base.BackColor



    #endregio

    #region Clean Up Cod

    /// <summary>
    /// Clean up any resources being used
    /// </summary
    protected override void Dispose( bool disposing

    if( disposing

    if(components != null

    components.Dispose()


    base.Dispose( disposing )


    #endregio

    #region Component Designer generated cod
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor
    /// </summary
    private void InitializeComponent(

    components = new System.ComponentModel.Container()

    #endregio

    #region Propertie

    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)
    [DefaultValue(typeof(System.Drawing.Color), "System.Drawing.SystemColors.Window")
    public new Color BackColo

    ge

    return mBackColor

    se

    mBackColor = value
    SetColour();





    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)
    [DefaultValue(typeof(bool), "true")
    public new bool Enable

    ge

    return base.Enabled

    se

    base.Enabled = value
    SetColour()




    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)
    [DefaultValue(typeof(System.Drawing.Color), "System.Drawing.SystemColors.Window")
    public Color LightColo

    ge

    return mLightColor

    se

    mLightColor = value
    SetColour()




    #endregio

    #region Protected Override Method

    protected override void OnMouseEnter(EventArgs e

    base.OnMouseEnter (e)
    mIsMouseOver = true
    SetColour()



    protected override void OnMouseLeave(EventArgs e

    base.OnMouseLeave (e)
    mIsMouseOver = false
    SetColour()




    protected override void OnGotFocus(EventArgs e

    base.OnGotFocus (e)
    SetColour()



    protected override void OnLostFocus(EventArgs e

    base.OnLostFocus (e)
    SetColour()




    #endregio

    #region Private Method

    private void SetColour(

    if(mIsMouseOver || base.Focused

    base.BackColor = mLightColor

    els

    base.BackColor = mBackColor




    #endregio


    -------------------------------------------------------------------------------

    Please help - I'm going insane!

    Thanks in advance

    Steve
    Steve Barker, Jan 22, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Allan Ebdrup
    Replies:
    11
    Views:
    654
    Walter Wang [MSFT]
    Jul 26, 2007
  2. J.Marsch

    Persisting Design-time generated value

    J.Marsch, Oct 7, 2003, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    130
    Mike Clay
    Oct 13, 2003
  3. Peter

    properties not showing in properties window at design time

    Peter, Dec 10, 2003, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    208
    Lostinet.Web Support
    Dec 10, 2003
  4. cpnet

    Persisting control properties at design time

    cpnet, Apr 19, 2004, in forum: ASP .Net Building Controls
    Replies:
    15
    Views:
    279
    Jeffrey Tan[MSFT]
    May 10, 2004
  5. jebecker@_NO_SPAM_.pointroll.com

    Issues Persisting Design time changes to page source

    jebecker@_NO_SPAM_.pointroll.com, Jul 13, 2006, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    114
    jebecker@_NO_SPAM_.pointroll.com
    Jul 14, 2006
Loading...

Share This Page