How do I add a combobox to a VB.net PropertyGrid

I have a PropertyGrid on a simple VB.net Form.

The following class seems to work in the property grid without problem.  I would like to add a property that would add a combobox to the property grid to allow users to select an item from _property3.  

What attributes do I need to specify to use a stock combo box?

Public Class CurrentSimulationProperties

    Private _property1 As Long = -1                        
    Private _property2 As String = "Property 2"
    Private _property3 As List(Of String)
   
    <Description("Property 1"), _
     Category( "My Properties") > _
    Public Property Property1 As Long
        Get
            Return _property1
        End Get
        Set(ByVal value As Long)
            _property1 = value
        End Set
    End Property

    <Description("Property 2"), _
     Category( "My Properties")> _
    Public Property Property2 As String
        Get
            Return _property2
        End Get
        Set(ByVal value As string)
            _property2 = value
        End Set
    End Property

End Class
MDKIMZEYAsked:
Who is Participating?
 
Miguel OzSoftware EngineerCommented:
Check:
http://gaaton.blogspot.com/2007/11/how-to-add-combobox-to-propertygrid.html
http://www.codeproject.com/KB/tabs/PropertyGridValidation.aspx
You need the Editor type. Quoting from link:
"In order to get the custom ComboBox to display in the PropertyGrid, you have to tell the PropertyGrid to display the data in the control. This is accomplished by adding another attribute, Editor, to the top of your property. You will have to do this for each property that you wish to show in a ComboBox.

 Collapse Copy Code[Editor( typeof( EnumGridComboBox ), typeof( UITypeEditor ) )]
[EnumList( typeof(SupplyStore.SupplyParts))]
[Category( "&" ), Description( "&" ), DisplayName( "&" )]
public SupplyStore.SupplyParts SupplyParts
{
    get { return _supplyPartsEnum; }
    set { _supplyPartsEnum = value; }
}"

0
 
Wayne Taylor (webtubbs)Commented:
Generally, the editor you would use for a List(Of T) object is a StringCollectionEditor (the same as the one used by the ListBox.Items property), which allows the user to add a list of strings to the property....

    <Description("Property 3"), _
     Category("My Properties"), _
     Editor("System.Windows.Forms.Design.StringCollectionEditor, System.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", _
        "System.Drawing.Design.UITypeEditor, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")> _
    Public Property Property3() As List(Of String)
        Get
            Return _property3
        End Get
        Set(ByVal value As List(Of String))
            _property3 = value
        End Set
    End Property

Wayne
0
 
Miguel OzSoftware EngineerCommented:
Glad you agree with me Wayne
0
 
Éric MoreauSenior .Net ConsultantCommented:
0
 
MDKIMZEYAuthor Commented:
Most helpful.  Thanks much!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.