Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Subclassing -Newbie!
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00886878
Message ID:
00886935
Views:
13
Shawn,

>1) i have MM framework, i am trying to subclass the label(simplist element)
>2) add a property to all my custom classes to hold a string
>3) create a copy of the base class element and use this element for now and later i can add code to it as i see fit

If you take a look at the source code for mmLabel, you'll see a good example of how to create a subclass and add custom properties. Here's how you might do it in your subclass:
using OakLeaf.MM.Main.Web.UI.WebControls;

namespace A4U.CommonControls.OurClasses
{
	/// <summary>
	/// Summary description for Class1.
	/// </summary>
	public class A4ULabel : OakLeaf.MM.Main.Web.UI.WebControls.mmLabel
	{
		public string MyCustomProperty
		{
			get { return this._myCustomProperty; }
			set { this._myCustomProperty = value; }
		}
		private string _myCustomProperty;

		public A4ULabel()
		{
			//
			// how do i override the text value onload of the object
			//
			this.MyCustomProperty = "Override the value";
		}
	}
}
If you don't want this property visible in the VS .NET Property Window, you can use set the Browsable attribute to false:
[Browsable(false)]
public string MyCustomProperty
{
	get { return this._myCustomProperty; }
	set { this._myCustomProperty = value; }
}
private string _myCustomProperty;
If you DO want the property visible in the VS .NET Property Window, you can set the Browsable attribute to true, and use other attributes to specify the Description, and Default Value of the property:
[Browsable(true), Category("Behavior"), 
Description("This is a description of my custom property"),
DefaultValue("This is the default value")]
public string MyCustomProperty
{
	get { return this._myCustomProperty; }
	set { this._myCustomProperty = value; }
}
private string _myCustomProperty;
Regards,
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform