codeGEN
codeGEN

Reputation: 714

Create a property from a structure

I am tying to create a property for a usercontrol to set values based a structure that I have defined. Here is the code that I am using to create the structure and the property

Private fooList As List(Of Structure_Foo)

    Public Structure Structure_Foo
        Dim a As Integer
        Dim b As Integer
    End Structure

    Public Property Foo As List(Of Structure_Foo)
        Get
            Return fooList
        End Get
        Set(ByVal value As List(Of Structure_Foo))
            fooList = value
        End Set
    End Property

Example of the requirement

I need to be able to set the values for the structure as list collection from the designer property window as shown in the image above.

Upvotes: 1

Views: 1880

Answers (1)

Jens
Jens

Reputation: 6375

Change your structure to

Public Structure Structure_Foo
    Public Property a As Integer
    Public Property b As Integer
End Structure

The Visual Studio editor only lists properties, not fields. That goes for all the attribute dialogs. If you want to edit fields you probably need to create a custom designer for the control.

http://msdn.microsoft.com/en-us/library/h51z5c0x.aspx

Upvotes: 3

Related Questions