Returning the index number of listbox

Discussion in 'ASP .Net' started by Maziar Aflatoun, May 13, 2005.

  1. Hi,

    Does anyone know how I can return the index number of a ListBox?

    Ex. How do I use lbxMyListBox.Items.IndexOf to search for the item that has
    a Text="Name"

    Thanks
    Maz.
    Maziar Aflatoun, May 13, 2005
    #1
    1. Advertising

  2. Could you not do this whith a foreach?

    Jon

    "Maziar Aflatoun" wrote:

    > Hi,
    >
    > Does anyone know how I can return the index number of a ListBox?
    >
    > Ex. How do I use lbxMyListBox.Items.IndexOf to search for the item that has
    > a Text="Name"
    >
    > Thanks
    > Maz.
    >
    >
    >
    =?Utf-8?B?Sm9u?=, May 13, 2005
    #2
    1. Advertising

  3. Maziar Aflatoun

    Teemu Keiski Guest

    Dim index As Integer =
    lbxMyListBox.Items.IndexOf(lbxMyListBox.Items.FindByText("Name"))

    If you need to look for a value instead of text, use FindByValue method

    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU


    "Maziar Aflatoun" <> wrote in message
    news:...
    > Hi,
    >
    > Does anyone know how I can return the index number of a ListBox?
    >
    > Ex. How do I use lbxMyListBox.Items.IndexOf to search for the item that
    > has a Text="Name"
    >
    > Thanks
    > Maz.
    >
    >
    Teemu Keiski, May 13, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. blenderdude
    Replies:
    0
    Views:
    977
    blenderdude
    Aug 3, 2003
  2. DC Gringo
    Replies:
    0
    Views:
    398
    DC Gringo
    Apr 6, 2004
  3. kent
    Replies:
    1
    Views:
    875
    Andrew de la Harpe
    May 3, 2004
  4. Simon Prince
    Replies:
    2
    Views:
    3,323
    =?Utf-8?B?TWljaGFlbCBUYXlsb3I=?=
    Oct 19, 2004
  5. Tomasz Chmielewski

    sorting index-15, index-9, index-110 "the human way"?

    Tomasz Chmielewski, Mar 4, 2008, in forum: Perl Misc
    Replies:
    4
    Views:
    279
    Tomasz Chmielewski
    Mar 4, 2008
Loading...

Share This Page