Determing the ordinal position of items in ListBox

  • Thread starter Thread starter SamIAm
  • Start date Start date
S

SamIAm

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
 
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
 
Use the IndexOf property

int indx = ListBox.Items IndexOf(ListBox.Items.FindItemByValue('my_value');
 
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 said:
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 said:
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
 
Back
Top