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!

Common Attributes for Properties and Events

The commonly used attribute classes from the System.ComponentModel namespace are listed below. These classes can be extended.

Attributes for Properties and Events

Note Attributes for events are applied to the AddOn<EventName> method that attaches event delegates to the event. When the attribute is provided, the form designer is informed how the event named <EventName> should be displayed in the events window.
BrowsableAttribute
Specifies whether a property or an event should be displayed in the property window. To hide a property or event from the property window, set BrowsableAttribute.NO.
[C#]    
[Browsable(false)]
CategoryAttribute
Specifies the name of the category that a given property or event should be grouped in. When categories are used, component properties and events can be displayed in logical groupings in the property window.
[C#]
[Category("Appearance")] 
DescriptionAttribute
Defines a small block of text to be displayed at the bottom of the property window when the user selects a property.
[C#]
[Description("The image associated with the control")]

Attributes for Properties

BindableAttribute
Specifies whether a property is appropriate to bind data to.
[C#]
[Bindable(true)]
DefaultPropertyAttribute
Specifies the default property for the component.
DefaultValueAttribute
Sets a simple default value. DefaultValueAttribute results in the following:
  • There is visual indication in the property window if a property has been modified.
  • The user can right-click a property and choose Reset to restore the property to its default value.
  • More efficient code is generated.

The Visual Studio Forms Designer supports two-way editing. The user can modify a form in the Forms Designer or through code. When the form is modified in the Forms Designer, it generates code and inserts it into the user’s file. To avoid generating code for every property in every control, the Forms Designer will always check to see if the property has been tagged as changed. If it has not been tagged, then code for the property will not be persisted in the form.

[C#]
//The constructor for DefaultValueAttribute is overloaded.
//Constructors are provided for all primitive types, as well
//as for user defined types.
[DefaultValue("")]
public string GetHelpText{...}
LocalizableAttribute
Specifies that a property may be localized. Any properties that have this attribute will be automatically persisted into the resources file, when users choose to localize forms. No other changes are needed to the component to support localization, thus simplifying the localization process.
[C#]
[Localizable(false)]
PersistableAttribute
Specifies whether a property displayed in the property window should be persisted into code. To disable persistence, set PersistableAttribute.NO.
[C#]
[Persistable(PersistableSupport.None)]

Attributes for Events

DefaultEventAttribute
Specifies the default event for the component.

In addition to using the attribute classes defined in the class library, you can also define your own attribute classes. Please refer to your programming language documentation for information about creating your own attribute classes.