views:

257

answers:

2

I'd like to add a property which represents a collection of controls to a component and have a collection editor with which I can easily select the controls that belong to the collection. VS does almost what I want automatically with the following code:

    Private _controls As New List(Of Control)
    <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _
    Public ReadOnly Property SelectedControls() As List(Of Control)
        Get
            Return _controls
        End Get
    End Property

I get the default CollectionEditor, can add and remove controls, and the collection is serialized.

The problem is that I don't want to add new controls, I want to select multiple controls from the other available controls on the form. Is there any easy/standard way to do this, or will I have to write my own collection editor and run through the controls collection?

Although there's plenty of material on collection editors (UITypeEditors) and other design-time topics, I haven't been able to find any links demonstrating this exact behaviour, so any help is appreciated.

A: 
Tom Juergens
A: 

Would you mind sharing how you did this? I am trying to do the same thing and I'm struggling to get it to work. Thanks.

Phil Brown
Sure, I'll edit my answer to give an overview and see if I can extract the relevant parts and give you a (temporary) download link. Can't get started right away; I'll be back in a couple of hours.
Tom Juergens