开发者

How to show a form's custom property at design time?

开发者 https://www.devze.com 2023-01-21 04:12 出处:网络
I have a form where I have created a custom property, DataEntryRole, and set its Browsable attribute to True, as shown:

I have a form where I have created a custom property, DataEntryRole, and set its Browsable attribute to True, as shown:

<Browsable(True)> _
Public Property DataEntryRole() As UserRole.PossibleRoles
    Get
        Return mDataEntryRole
    End Get
    Set(ByVal value As UserRole.PossibleRoles)
        mDataEntryRole = value
    End Set
End Property

(UserRole.PossibleRoles is an Enum)

When I view the designer for my form, DataEntryRole doesn't appear in the property box. I assume that it should appear if I were to create another form that inherited from this base form, 开发者_JAVA百科but that's not what I want. I want this property to show up in my current form.

Is this possible? If so, how? If not, what in your opinion is a viable alternative?


In the end, I made a subclass of Form and added the properties I wanted to that subclass. I then set my form to inherit from that subclass and the properties now display in the properties box. I'm still curious about whether there is a way to do what I asked without making a Form subclass.


I believe the reason why your custom property isn't showing up in the Properties window is because you are using a custom enumeration. If you use primitive types (int, bool, string, etc.), then they show up because they are easily editable from within the Properties window.

0

精彩评论

暂无评论...
验证码 换一张
取 消