NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Defining a Property

For an overview of properties see Properties. There are a few important considerations to remember when defining a property:

The following code fragment defines a custom property EndColor for the custom control FlashTrackBar.

[C#]
public class FlashTrackBar : RichControl {
...
//private data member endColor
private Color endColor = Color.LimeGreen;

//Attributes for the property that tell the designer to display
//it in the Flash grouping. 
        [
        Category("Flash"),
        Description("The ending color of the bar.")
        ]
//public property EndColor that accesses endColor
        public Color EndColor {
            get {
                return endColor;
            }
            set {
                endColor = value;
                if (baseBackground != null && showGradient) {
                    baseBackground.Dispose();
                    baseBackground = null;
                }
//Invalidate calls the OnPaint method that redraws the control
                Invalidate();
            }
        }
...
}

The following code fragment associates a type converter and a UI type editor with the property Value. In this case Value is an integer and has a default type converter, but the idea is to display it as a percentage. The UI type editor, FlashTrackBarValueConverter, allows the percentage to be displayed visually. This example also shows that the type converter or editor specified by the TypeConverter or Editor attribute overrides the default converter.

[C#]
        [
        Category("Flash"), 
        TypeConverter(typeof(FlashTrackBarValueConverter)),
        Editor(typeof(FlashTrackBarValueEditor), typeof(UITypeEditor)),
        Description("The current value of the track bar.  You may enter an
        actual value or a percentage.")
        ]
        public int Value {…}