By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,239 Members | 1,493 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,239 IT Pros & Developers. It's quick & easy.

ComboBox And ListViewItem

P: n/a
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?
Nov 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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" <Ji*******@nospam.com> wrote in message
news:Xn********************************@207.46.248 .16...
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?

Nov 20 '05 #2

P: n/a
* Jim Heavey <Ji*******@nospam.com> scripsit:
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!).

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3

P: n/a
Actually it does. That's the string that the OP sees.
To the OP: Set the DisplayMember of your combobox to "Text"

/claes
"solex" <so***@nowhere.com> wrote in message
news:O9**************@TK2MSFTNGP12.phx.gbl...
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" <Ji*******@nospam.com> wrote in message
news:Xn********************************@207.46.248 .16...
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?


Nov 20 '05 #4

P: n/a
Thank you for the info I will also look into this...
"Claes Bergefall" <cl********************@frontec.se> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Actually it does. That's the string that the OP sees.
To the OP: Set the DisplayMember of your combobox to "Text"

/claes
"solex" <so***@nowhere.com> wrote in message
news:O9**************@TK2MSFTNGP12.phx.gbl...
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" <Ji*******@nospam.com> wrote in message
news:Xn********************************@207.46.248 .16...
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?



Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.