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
 

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

Back
Top