How do I add a combobox to a PropertyGrid

Posted on 2010-01-08
Last Modified: 2012-08-13
I have a PropertyGrid on a simple 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
            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
            Return _property2
        End Get
        Set(ByVal value As string)
            _property2 = value
        End Set
    End Property

End Class
Question by:MDKIMZEY
    LVL 35

    Accepted Solution

    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; }

    LVL 46

    Assisted Solution

    by:Wayne Taylor (webtubbs)
    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)
                Return _property3
            End Get
            Set(ByVal value As List(Of String))
                _property3 = value
            End Set
        End Property

    LVL 35

    Expert Comment

    by:Miguel Oz
    Glad you agree with me Wayne
    LVL 69

    Assisted Solution

    by:Éric Moreau

    Author Closing Comment

    Most helpful.  Thanks much!

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now