anon271334
anon271334

Reputation:

Adding Custom Properties

I have created a user control, and now I want to add custom properties to it so they will appear in the Properties toolbar in Vis. Studio. How can this be done?

My custom property will be: "Animation Type" with options "Fade | Blink | Scroll | Blend"

thank you

Upvotes: 2

Views: 237

Answers (1)

thecoop
thecoop

Reputation: 46148

The designer automatically reads properties of the class and adds them to the properties view. So all you need to do is to create the property with a public getter and setter

public AnimationType AnimationType { get; set; }

There are extra attributes you can apply to the property, for example DefaultValue or EditorBrowsable, that change how it appears in the properties view. All the relevant attributes are in the System.ComponentModel namespace.

Upvotes: 1

Related Questions