473,406 Members | 2,954 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,406 software developers and data experts.

Hopefully an easy soltion to this (listbox question)

I have a listbox, and i need to show a text string for selection, but each
item is tied to a number (not visible) i need to select the visible text and
have it return the number value, i know its possible with data sets and such
useing the display column and value column settings, but what if you arnt
useing a data set? how would i do this? thanks
Nov 20 '05 #1
4 944
Hi Brian,

Not as easy as you might think, at least I haven't found an easy way. One
solution: create a shadow array with both the string and the number as a
part of it. Then find the string in the array and you will get the
corresponding number. If, on the other hand, the string may be repeated,
you will have to use something like hashtables or any other key/value set
data type.

HTH,

Bernie Yaeger

"Brian Henry" <br******@adelphia.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I have a listbox, and i need to show a text string for selection, but each
item is tied to a number (not visible) i need to select the visible text and have it return the number value, i know its possible with data sets and such useing the display column and value column settings, but what if you arnt
useing a data set? how would i do this? thanks

Nov 20 '05 #2
found one myself :)

Dim USStates As New ArrayList()
USStates.Add(New USState("Washington", "WA"))
USStates.Add(New USState("West Virginia", "WV"))
USStates.Add(New USState("Wisconsin", "WI"))
USStates.Add(New USState("Wyoming", "WY"))

ListBox1.DataSource = USStates
ListBox1.DisplayMember = "LongName"
ListBox1.ValueMember = "ShortName"

"Brian Henry" <br******@adelphia.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I have a listbox, and i need to show a text string for selection, but each
item is tied to a number (not visible) i need to select the visible text and have it return the number value, i know its possible with data sets and such useing the display column and value column settings, but what if you arnt
useing a data set? how would i do this? thanks

Nov 20 '05 #3
Hi Brain,

Forget the listbox had those properties - you're quite right.

Bernie
"Brian Henry" <br******@adelphia.net> wrote in message
news:Ou**************@TK2MSFTNGP11.phx.gbl...
found one myself :)

Dim USStates As New ArrayList()
USStates.Add(New USState("Washington", "WA"))
USStates.Add(New USState("West Virginia", "WV"))
USStates.Add(New USState("Wisconsin", "WI"))
USStates.Add(New USState("Wyoming", "WY"))

ListBox1.DataSource = USStates
ListBox1.DisplayMember = "LongName"
ListBox1.ValueMember = "ShortName"

"Brian Henry" <br******@adelphia.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I have a listbox, and i need to show a text string for selection, but each item is tied to a number (not visible) i need to select the visible text

and
have it return the number value, i know its possible with data sets and

such
useing the display column and value column settings, but what if you arnt useing a data set? how would i do this? thanks


Nov 20 '05 #4
* "Brian Henry" <br******@adelphia.net> scripsit:
I have a listbox, and i need to show a text string for selection, but each
item is tied to a number (not visible) i need to select the visible text and
have it return the number value, i know its possible with data sets and such
useing the display column and value column settings, but what if you arnt
useing a data set? how would i do this? thanks


I remember I posted a solution to your previous thread. Have a look
there at all replies.

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

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

Similar topics

4
by: f_salazar | last post by:
English Version !! Hi !! I have a page with a Form, inside the form I have listbox with 'X' elements. Wend I submit the page, an ASP process inside the page have to read those elements and...
2
by: Peteroid | last post by:
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...
3
by: Paul W | last post by:
I am populating listbox with a datreader. DateReader sqlcommand is dynamic, based on several user selections Listbox DataValueField is set to the tables primary key Listbox DataTextField is...
5
by: Eddie Clark | last post by:
I'm trying to access the items in a listbox from a client-side vb script. <asp:listbox id="ListBox1" style="Z-INDEX: 101; LEFT: 16px; POSITION: absolute; TOP: 120px" runat="server" Width="400px"...
2
by: louise raisbeck | last post by:
Hi there. I am a little confused. SelectedValue is a property of ListBox and dropdownlist. However it isnt in the list of properties in intellisence (html view i am not talking about code behind...
8
by: Steve Schroeder | last post by:
For some reason I cannot get the OnSelectedIndexChanged event to fire for a listbox I have on a page. I'm able to populate the listbox with data from a stored procedure, but cannot trigger the...
3
by: BY | last post by:
Hi, This is my code and it works fine... Dim Conn As OleDb.OleDbConnection Dim Cmd As OleDb.OleDbCommand Dim Reader As OleDb.OleDbDataReader Dim i As Integer Conn = New...
1
by: superjacent | last post by:
Hope someone can point me in the right direction. When opening a form the 'click' event of the ListBox is invoked (run). I thought the 'click' event of the ListBox is only invoked when clicking...
0
by: IMAFriend | last post by:
Hello everyone. This maybe is easy, but I'm stuck. I'm using visual basic.net. And this is with the enumwindows function. But that isn't relevant. If I have a sub that just simply will...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.