470,624 Members | 2,153 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,624 developers. It's quick & easy.

ComboBox in User Control

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

Nov 16 '05 #1
1 5916
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(DesignerSerializat ionVisibility.Content),
Editor("System.Windows.Forms.Design.StringCollecti onEditor, System.Design",
typeof(System.Drawing.Design.UITypeEditor))]
public ComboBox.ObjectCollection Items
{
get{ return comboBox.Items; }
}

-Rachel

"Rachel Suddeth" <ra****@bldhound.com> wrote in message
news:uc**************@TK2MSFTNGP11.phx.gbl...
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

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by David Sworder | last post: by
5 posts views Thread by Aaron Ackerman | last post: by
30 posts views Thread by dbuchanan | last post: by
reply views Thread by Frnak McKenney | last post: by
6 posts views Thread by tbrown | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.