Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Properties not persisting at design time.

Reply
Thread Tools

Properties not persisting at design time.

 
 
Steve Barker
Guest
Posts: n/a
 
      01-22-2004
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(DesignerSerializat ionVisibility.Content)
[DefaultValue(typeof(System.Drawing.Color), "System.Drawing.SystemColors.Window")
public new Color BackColo

ge

return mBackColor

se

mBackColor = value
SetColour();





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

ge

return base.Enabled

se

base.Enabled = value
SetColour()




[DesignerSerializationVisibility(DesignerSerializat ionVisibility.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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
extender provider properties not persisting ! JezB ASP .Net 1 06-22-2004 10:04 AM
Persisting control properties at design time cpnet ASP .Net Building Controls 15 05-10-2004 01:52 AM
Complex properties (Button) not persisting in webcontrol Phillyboy123 ASP .Net Building Controls 1 01-15-2004 07:55 PM
Complex properties (Button) not persisting in webcontrol Phillyboy123 ASP .Net Web Controls 0 11-19-2003 02:20 PM
Persisting properties in templates and not the control itself Alessandro Zifiglio ASP .Net Building Controls 0 11-09-2003 11:31 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57