Question

How can I access a user controls properties from the design view?

For example, I have a custom user control called NoteBox with a Title property.

I'd like to be able to set the Title property thorough design view and have that show up on my form, just like you would with the Text property of a label, button, or groupbox.

Is this possible?

Was it helpful?

Solution

You can do this, and it should, for the most part, just work automatically when you drag your UserControl onto a designer. There are many attributes, such as CategoryAttribute and similar, that help the PropertyGrid determine how to display your control properties.

For details, I recommend reading Getting the Most Out of the .NET Framework PropertyGrid Control. That article details all of the appropriate attributes, as well as demonstrating how to make custom editors for your properties as needed, etc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top