ComboBox in User Control

R

Rachel Suddeth

When I put a ComboBox on a form, I can enter strings through the designer to
fill Items collections. I have put a ComboBox in a UserControl, and exposed
the the Items collections with the same type...

public class ControlWithComboBox : MyControls.BaseControl, IDataEntryControl
{
...
protected System.Windows.Forms.ComboBox comboBox;
...
public ComboBox.ObjectCollection Items
{
get{ return comboBox.Items; }
}
...
}

Now I get a different TypeEditor in the desiger, and it's useless. Is there
something simple I'm missing to tell VS that this field can be changed in
the same way as the ComboBox.Items?

Thanks,
Rachel

______________________________________________________________

Roydan Enterprises Ltd
602 North 9th Street
Manitowoc, WI 54220-3924

1-800-236-6906
(920)-684-3688
Fax: (920)-684-3630
 
R

Rachel Suddeth

Since no one seemed to know this, I thought I'd post the solution I finally
figured out. It's not well documented in the help, and I thought someone
else might like to know... there are 2 things (attributes). You need to give
the elements of the collection DesignerVisibility, and you need to use the
StringCollectionEditor UITypeEditor.

[Description("Gets the collection of items displayed by the current combo
box editor."),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
Editor("System.Windows.Forms.Design.StringCollectionEditor, System.Design",
typeof(System.Drawing.Design.UITypeEditor))]
public ComboBox.ObjectCollection Items
{
get{ return comboBox.Items; }
}

-Rachel
 

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