Based on the information I found in the MSDN Library, I found a solution.
By setting the DisplayMember property of the ComboBox to a property name
that contains the text to be shown, the appropriate text is shown for my
usercontrol.
I'm still confused as to why the ToString method was not used for a
UserControl. If anyone does have an explanation I wouldn't mind hearing it.
In the meantime, I can at least move on.
[quoted text, click to view] "Jason Barnett" <jwb@wbai.com> wrote in message
news:ejyo1IY1FHA.3856@tk2msftngp13.phx.gbl...
> I'm designing a UserControl that contains a ComboBox and a Panel. I'd
> like to swap the control contained in the Panel (a custom "child"
> usercontrol) based on the selection in the ComboBox. One way that I
> thought I might do this is to override the ToString on the "child" control
> and add that control to the ComboBox. Then, on the SelectedIndexChanged
> event of the ComboBox I could clear the contents of the Panel and add the
> SelectedItem.
>
> I've created classes before that don't inherit from anything (except, of
> course, Object) and overrode ToString. Then, after adding the object to a
> ComboBox, the ToString value was shown in the drop-down list. However,
> the ComboBox shows a blank item in its list if the object added is a
> UserControl. Does anyone have any ideas why this is happening and how I
> might resolve this? I'd appreciate the help.
>