473,387 Members | 1,463 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,387 software developers and data experts.

Determing the ordinal position of items in ListBox

Hi

I have a ListBox called lstListOfStuff

I want to get the ordinal position of a ListItem so that I can insert a new
ListItem below it. How do I do this? I cannot find any members to give me
the index position of an item?

Thanks,

S
Nov 15 '05 #1
3 8950
i hope this is what you need.

listBox1.SelectedIndex --> get selected item's index
listBox1.Items[0] --> access each item
listBox1.Items.Count --> get item count

hope this helps

--
gani
pls visit http://thedeveloperscorner.com.ph

"SamIAm" <sa****@rubbachicken.com> wrote in message
news:O1**************@tk2msftngp13.phx.gbl...
Hi

I have a ListBox called lstListOfStuff

I want to get the ordinal position of a ListItem so that I can insert a new ListItem below it. How do I do this? I cannot find any members to give me
the index position of an item?

Thanks,

S

Nov 15 '05 #2
Use the IndexOf property

int indx = ListBox.Items IndexOf(ListBox.Items.FindItemByValue('my_value');
"SamIAm" <sa****@rubbachicken.com> wrote in message
news:O1**************@tk2msftngp13.phx.gbl...
Hi

I have a ListBox called lstListOfStuff

I want to get the ordinal position of a ListItem so that I can insert a new ListItem below it. How do I do this? I cannot find any members to give me
the index position of an item?

Thanks,

S

Nov 15 '05 #3
Thanks for the reply gani

I am aware of those members. I am trying to determine the index of a
particular item i.e.
ListItem foundItem = listBox1.items.FindByValue("someValue");
no that I have the item how do I determine its position in the ListBox. How
do I insert a new item just after it?

Hope that is clear,

S

"gani" <a@a.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
i hope this is what you need.

listBox1.SelectedIndex --> get selected item's index
listBox1.Items[0] --> access each item
listBox1.Items.Count --> get item count

hope this helps

--
gani
pls visit http://thedeveloperscorner.com.ph

"SamIAm" <sa****@rubbachicken.com> wrote in message
news:O1**************@tk2msftngp13.phx.gbl...
Hi

I have a ListBox called lstListOfStuff

I want to get the ordinal position of a ListItem so that I can insert a

new
ListItem below it. How do I do this? I cannot find any members to give me the index position of an item?

Thanks,

S


Nov 15 '05 #4

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

Similar topics

3
by: darren | last post by:
How, using asp.net (vb.net), can I remove multiple selected items from a listbox. Everything I try does not seem to work. Thanks in advance.
1
by: Jim Geissman | last post by:
Is there a neat way to find an ordinal value from a table, for example the median or 95th percentile value in a column, without walking through the table in ascending or descending order? ...
14
by: Zenobia | last post by:
Hello folks, Is it possible to position an item within a <td> element? For instance see below. The table has multiple rows, one for each database record. Each row has 3 hrefs associated with it...
1
by: SamIAm | last post by:
Hi I have a ListBox called lstListOfStuff I want to get the ordinal position of a ListItem so that I can insert a new ListItem below it. How do I do this? I cannot find any members to give me...
24
by: Donald Grove | last post by:
I want to populate an array with values from an ado recordset (multiple rows) I use the absolute position of the cursor in the recordset to define the row of my array to be populated. I have a...
5
by: Randy | last post by:
Hi, I'm have a form with a listbox and a few textboxes on it. Based on the user's selection in the listbox, I want the bindingsource to update the textboxes with the corresponding values. I have...
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: 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...
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,...

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.