문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top