473,386 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

ComboBox And ListViewItem

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
4 2943
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
* 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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jim Heavey | last post by:
I thought I could create a "ListViewItem" and then bind that item to a combox box, but perhaps that is was with an ASP.Net control. When I create a listViewItem and bind it to a combo box, it does...
2
by: John Smith | last post by:
Hey folks, I've got a combobox (DropDown List) in a windows form application which is bound to a DataSet. It's value is set to a numeric ID. It's visible text is set to a date. I need to make...
6
by: grs | last post by:
The following is a code example from the Microsoft MSDN. My question is on the following three lines of code: ListViewItem item1 = new ListViewItem("item1",0); ListViewItem item2 = new...
1
by: Ken Yu | last post by:
Hi, How can create image in ListView and ComboBox ? tks a lot ! Ken
0
by: reidarT | last post by:
I have found a good combobox with multiple fields The example shows filling the combobox from a listview, but I want to fill it with zip-code and cities from a database. The example is as follows:...
2
by: Hardik Shah | last post by:
Hi, I want to create menu , when my user right click from combo box's list item. I use Contextmenu property of combobox and assign menu for it, but it only effected when combobox's list item not...
4
by: dm1608 | last post by:
I'm used to setting the Text property and Value property of a ComboBox. I do not see this option for C# 2.0. Am I missing something? Basically, I'm trying to loop thru an ADO.NET reader object...
7
by: samoore33 | last post by:
I am trying to dynamically add items to a listbox or combobox. The items add to either, but when I look through those items, there is nothing there. If I choose an item, it shows up. Not sure...
3
by: james | last post by:
Hi, I am trying to duplicate the contents of a combobox to another. I tried: cmbBoxA.Items.AddRange(cmbBoxB.Items); but it says it can't convert a combobox objectcollection to object. I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.