Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple values in the Listbox item collection editor? 1

Status
Not open for further replies.

ookete

Programmer
Oct 5, 2004
180
US
I would like to have a Listbox with a hidden value member and a visible display member. I have done this with setting the DataSource to a table, for example, but I haven't been able to do this just using the item collection editor screen.

I don't want to go through the hassle of setting up a datasource when all I need is something like:
Code:
Value  Display
1      Sam
2      Victor
3      Holly
I have tried to separate each like with a semicolon (like in MS Access) and it shows the literal display with the semicolon in it. Anyone know how to do this?

Thanks!
 
I don't quite understand your question. Are the list items static or are you binding to a datasource?

If they are static, why isn't the Item Collection working?


--
Not until I became a Network Administrator did the error message "See your Network Administrator for assistance" become petrifying.
 
You don't need a datasource. A listbox accepts objects. The design-time editor lets you key in strings. Strings obviously only have one "value."

You can make your own custom type, set properties, add them to the listbox in code, and set the display member and value members of the listbox to your custom type's properties.
 
Mike555, the values are static. The item collection editor is not working for multi-column entries, like in my sample table above... where you want one column to the hidden "Value" and the other column to be the "Display". The collection editor only seems to work for a single-column list of static values, not a multi-column list.

RiverGuy, that looks like what I need to do. Thank you. More coding than I was hoping for, but that's the solution.
 
ookete, you should be able to use a Structure.

Code:
Public Structure DisplayValue
  public Display as String
  public Value as String
end structure

-Rick

----------------------
[banghead]If you're about to post an ASP.Net question,
please don't do it in the VB.Net forum[banghead]

[monkey] I believe in killer coding ninja monkeys.[monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top