Setting combo box items property?

D

David Veeneman

I am building a user control that has a combo box (comboBoxMain) as a
constutient control. The user control has an Items property, which will set
the items of the combo box. I want the user control Items property to be
browsable at design-time, so the user of the control can click the
properties, enter a list of items in the String Collection Editor and have
them appear in the combo box.

Here's the code I'm using now:

[Browsable(true)]
[EditorBrowsable(EditorBrowsableState.Always)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[Editor("System.Windows.Forms.Design.StringCollectionEditor,System.Design",
"System.Drawing.Design.UITypeEditor, System.Drawing")]
[Description("The list of objects in the combo box")]
public ComboBox.ObjectCollection Items
{
get { return comboBoxMain.Items; }
set { comboBoxMain.Items = value; }
}

The Editor attribute brings up the String Collection Editor, but it isn't
retrieving any items I place in the combo box. And nothing that I enter in
the editor is making it back to the combo box.

What do I need to do to complete the connection between the user control
Items property and the combo box Items property? Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top