Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to check if an item already exists in a listbox? Give an Example

How to check if an item already exists in a listbox? Give an Example

Scheduled Pinned Locked Moved ASP.NET
tutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mowli
    wrote on last edited by
    #1

    Hi, How to check if an item already exists in a listbox? Give an Example thanks aparna

    M F 2 Replies Last reply
    0
    • M mowli

      Hi, How to check if an item already exists in a listbox? Give an Example thanks aparna

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Hi there, The Items property of the ListBox control is of the ListItemCollection classs, and this class supports some utility methods which you can use do that like Contains ..., In addition, you can walk through the item collection and do the checking. For more information, see ListItemCollection Members[^]

      1 Reply Last reply
      0
      • M mowli

        Hi, How to check if an item already exists in a listbox? Give an Example thanks aparna

        F Offline
        F Offline
        FriendlyFiend
        wrote on last edited by
        #3

        You can use the ListItemCollection's FindByValue/FindByText methods to see if a value exists in the ListBox. eg. if(null==ListBox1.Items.FindByValue(NewItem.Value))ListBox1.Items.Add(NewItem)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups