Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ComboBox in User Control

32 views
Skip to first unread message

Rachel Suddeth

unread,
Dec 20, 2004, 12:03:38 PM12/20/04
to
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

Rachel Suddeth

unread,
Jan 20, 2005, 11:31:17 AM1/20/05
to
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

"Rachel Suddeth" <rac...@bldhound.com> wrote in message
news:uc7xaXr5...@TK2MSFTNGP11.phx.gbl...

0 new messages