473,386 Members | 1,823 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.

ListBox Item Objects: what is displayed?

I'm going to be using a ListBox in my managed C++ application, and have a
question. Why are the Items you Add to a ListBox in the form of generic
Object*'s? I believe a ListBox displays a table of selectable options via
multiple lines (or columns) of TEXT, so why doesn't Add merely take a
String* ? How does it know what to display (i.e., the text of each Item
listing) with a generic Object* (or do all Object's have some Text property
ListBox knows to display to represent it)? Put more to the point, if I Add
an Item which ISN'T a String*, what does the ListBox display?

Thanks in advance! : )

[==Peteroid==]
Nov 17 '05 #1
2 1341
You should look up DisplayMember and ValueMember, which are listbox
properties. I have never used it myself but you can use that to control what
is displayed in the listbox.

mosimu

"Peteroid" wrote:
I'm going to be using a ListBox in my managed C++ application, and have a
question. Why are the Items you Add to a ListBox in the form of generic
Object*'s? I believe a ListBox displays a table of selectable options via
multiple lines (or columns) of TEXT, so why doesn't Add merely take a
String* ? How does it know what to display (i.e., the text of each Item
listing) with a generic Object* (or do all Object's have some Text property
ListBox knows to display to represent it)? Put more to the point, if I Add
an Item which ISN'T a String*, what does the ListBox display?

Thanks in advance! : )

[==Peteroid==]

Nov 17 '05 #2
Thanks, I will :)

[==Peteroid==]

"mosimu" <mo****@discussions.microsoft.com> wrote in message
news:7B**********************************@microsof t.com...
You should look up DisplayMember and ValueMember, which are listbox
properties. I have never used it myself but you can use that to control
what
is displayed in the listbox.

mosimu

"Peteroid" wrote:
I'm going to be using a ListBox in my managed C++ application, and have a
question. Why are the Items you Add to a ListBox in the form of generic
Object*'s? I believe a ListBox displays a table of selectable options via
multiple lines (or columns) of TEXT, so why doesn't Add merely take a
String* ? How does it know what to display (i.e., the text of each Item
listing) with a generic Object* (or do all Object's have some Text
property
ListBox knows to display to represent it)? Put more to the point, if I
Add
an Item which ISN'T a String*, what does the ListBox display?

Thanks in advance! : )

[==Peteroid==]

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Luca | last post by:
Hello, I'm using a windows form in which there is a standard ListBox control. I want to add/remove objects from the ArrayList associated to the ListBox, and I want the ListBox immediately shows...
6
by: Grant Schenck | last post by:
Hello, This seems like it should be easy... I have a listbox on a .NET form. I add a new item to the list box. How can I associated a separate data value?
21
by: Bilal Abbasi | last post by:
I realize that you can add items to a list box as objects so you can have access to more than just one property like the itemindex in vb6. Question I have is how do I cause the listbox to show a...
3
by: Mitch | last post by:
Is the following a correct representation of the relationship of the selected index to selected item: INDEX ITEM 0 "item 1" 1 "item 2" 2 "item 3" and so on. I keep...
3
by: Kevin Walzer | last post by:
I'm trying to set the active item in a Tkinter listbox to my application's currently-defined default font. Here's how I get the fonts loaded into the listbox: ...
2
by: Ikke | last post by:
Hi everyone, I've created an ArrayList in which there are Objects of type 'Item'. Item is a simple class which holds a sequence and a link, of which the link should be displayed in the ListBox....
1
by: John | last post by:
Using Access 2007 I find that, on opening a form, a listbox control always displays one of the values in the list, even if no value has been selected. Thus, the first value in the list is...
0
by: LostInMd | last post by:
Hi All, I've got an owner drawn listBox where I draw and measure the items that I add to the listBox. For example, I have a listBox that can only display 10 characters on each horizontal line. ...
1
by: Sunray | last post by:
I have a form called the sales form and i have 2 sets of listboxes So what happens is. i add items form the bottom set of list boxes which are bound to a data base to the top set of list boxes which...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...

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.