Properties in Property Window

J Windebank

New member
Joined
Sep 5, 2007
Messages
1
Programming Experience
5-10
Hi all,

I am creating a custom control that currently has a heap of properties exposed to the Property Window in the Forms Designer by setting the attribute <Browsable(True)> and have no problems.

What I want to do though, if possible, is expose the properties of objects within this class to the Property Window. Does anybody know how/if this is possible?

Example:
VB.NET:
Class A

    Inherits System.Windows.Forms.Control

    Private mX As Integer
    Private B As New B()

    <Browsable(True)> _
    Public Property X() As Integer
        Get
            Return mX
        End Get
        Set(ByVal value As Integer)
            mX = value
        End Set
    End Property

End Class

Class B

    Private mY As Integer

    <Browsable(True)> _
    Public Property Y() As Integer
        Get
            Return mY
        End Get
        Set(ByVal value As Integer)
            mY = value
        End Set
    End Property

End Class
Property X is displayed in the Property window when I add the control to my form, but is it possible to get Property Y to? Either on it's own or under a "sub-heading" of "B"?

Thanks a lot,
Jordan
 
PropertyGrid will only display the browsable properties of a class instance, so you have to expose the B instance as a browsable property of A. Furthermore the PropertyGrid does only know how to present (and convert) basic types and types known to the Framework library, so for your property of custom type B you have to write a TypeConverter. See for example section "Displaying custom data types with expandable properties" in Code Project article Using PropertyGrid Part-I
 
Back
Top