473,386 Members | 1,786 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 index

Man the help in VB.NET is hard to use!!

Can somebody please tell me the syntax to find the index value a user has
chosen from a list of items in a listbox. Also, is there a way to use the
string value instead of the index number?

I'm trying to do something like...

if lstBox.items.index = 0 then
stuff...
end if

OR

if lstBox.items.index = "California" then
stuff...
end if

--
Jeff Ciaccio
Physics and AP Physics Teacher
Sprayberry High School; Marietta, GA
Blog: http://sprayberry.typepad.com/ciaccio

Jun 27 '08 #1
3 6959
On Jun 27, 8:22 pm, "Jeff Ciaccio" <non...@noreply.orgwrote:
Man the help in VB.NET is hard to use!!

Can somebody please tell me the syntax to find the index value a user has
chosen from a list of items in a listbox. Also, is there a way to use the
string value instead of the index number?

I'm trying to do something like...

if lstBox.items.index = 0 then
stuff...
end if

OR

if lstBox.items.index = "California" then
stuff...
end if

--
Jeff Ciaccio
Physics and AP Physics Teacher
Sprayberry High School; Marietta, GA
Blog:http://sprayberry.typepad.com/ciaccio
As i understood, you need to get "selected" index and item:

For index value you need "lstBox.SelectedItems" :

' -----------------------------------

f lstBox.SelectedIndex = 0 then
' stuff...
end if

' ---------------------------------
To get Selected Item you need "lstBox.SelectedItem" :

' --------------------------------

if lstBox.SelectedItem = "California" then
stuff...
end if

' -----------------------

Thanks,

Onur Güzel
Jun 27 '08 #2
On Jun 27, 8:36 pm, kimiraikkonen <kimiraikkone...@gmail.comwrote:
On Jun 27, 8:22 pm, "Jeff Ciaccio" <non...@noreply.orgwrote:
Man the help in VB.NET is hard to use!!
Can somebody please tell me the syntax to find the index value a user has
chosen from a list of items in a listbox. Also, is there a way to use the
string value instead of the index number?
I'm trying to do something like...
if lstBox.items.index = 0 then
stuff...
end if
OR
if lstBox.items.index = "California" then
stuff...
end if
--
Jeff Ciaccio
Physics and AP Physics Teacher
Sprayberry High School; Marietta, GA
Blog:http://sprayberry.typepad.com/ciaccio

As i understood, you need to get "selected" index and item:

For index value you need "lstBox.SelectedItems" :

' -----------------------------------

f lstBox.SelectedIndex = 0 then
' stuff...
end if

' ---------------------------------

To get Selected Item you need "lstBox.SelectedItem" :

' --------------------------------

if lstBox.SelectedItem = "California" then
stuff...
end if

' -----------------------

Thanks,

Onur Güzel
Sorry correcting first line of my post:

For index value you need "lstBox.SelectedIndex" :

' -----------------------------------

f lstBox.SelectedIndex = 0 then
' stuff...
end if

' ........

Thanks,

Onur Güzel
Jun 27 '08 #3
That did it - thanks!!
Jun 27 '08 #4

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...
1
by: Patty O'Dors | last post by:
Hi I have some code to create an ownerdrawn listbox (derived), and when I add an item to it, the bold text of the first item (the title, 'Collections and Maturities') mysteriously seems to get...
1
by: Edward | last post by:
I am having a terrible time getting anything useful out of a listbox on my web form. I am populating it with the results from Postcode lookup software, and it is showing the results fine. What...
4
by: Ron | last post by:
I've got a listbox that holds a list of groups. Users can select a group, hit the remove button and the group should be removed from the listbox. The only problem is that no matter which group you...
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...
11
by: John Dann | last post by:
I'm still struggling to find a way of reordering the items within the same single listbox with drag and drop. I think I've got the drag working but it's the drop code I can't figure out. What I...
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...
2
by: teo | last post by:
I have a Listbox, if I set EnableViewStarte = False the AutopostaBack fired by SelectedIndexChanged doesn't work. The 'SelectedIndexChanged' event should call
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: ...
7
by: Lit | last post by:
Hi, How can I capture the vertical scroll bar position for a Listbox. I have a Listbox of 100 items + when I click on it I post back remove the item selected. After returning to the client...
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: 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...
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...

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.