ComboBox And ListViewItem

  • Thread starter Thread starter Jim Heavey
  • Start date Start date
J

Jim Heavey

Can I load the ComboBox with ListViewItems? After I do load them into the
comboBox they display as "ListViewItem {"My Item"}. How do I get it to
display the text of the ListViewItem correctly?
 
Jim,

To display objects as you expect in a ComboBox the object must support an
Overridden version of the ToString property, apparently ListViewItem does
not.

Regards,
Dan
 
* Jim Heavey said:
Can I load the ComboBox with ListViewItems? After I do load them into the
comboBox they display as "ListViewItem {"My Item"}. How do I get it to
display the text of the ListViewItem correctly?

You will have to inherit from 'ListViewItem' and override the 'ToString'
property to return the text you want to be shown (untested!).
 
Actually it does. That's the string that the OP sees.
To the OP: Set the DisplayMember of your combobox to "Text"

/claes
 
Back
Top