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. General Programming
  3. C#
  4. How do i clear a list box

How do i clear a list box

Scheduled Pinned Locked Moved C#
helpcsharpvisual-studioquestion
3 Posts 2 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.
  • W Offline
    W Offline
    Wamuti
    wrote on last edited by
    #1

    Hi all. Is it that i am using VS .Net 2003 that there is no method to clear a list box once it is populated. I need to clear the list Box but every time i attempt using the method Clear() from Class ListControls, i get an error. please help.

    Wamuti: Any man can be an island, but islands to need water around them! Edmund Burke: No one could make a greater mistake than he who did nothing because he could do only a little.

    J 1 Reply Last reply
    0
    • W Wamuti

      Hi all. Is it that i am using VS .Net 2003 that there is no method to clear a list box once it is populated. I need to clear the list Box but every time i attempt using the method Clear() from Class ListControls, i get an error. please help.

      Wamuti: Any man can be an island, but islands to need water around them! Edmund Burke: No one could make a greater mistake than he who did nothing because he could do only a little.

      J Offline
      J Offline
      John Ad
      wrote on last edited by
      #2

      Hi Wamuti, Try using the following line of code if it is a Bound ListBox: this.listBox1.DataSource = null; For Unbound ListBox: this.listBox1.Items.Clear() I hope this would be helpful.

      John Adams ComponentOne LLC. www.componentone.com

      modified on Thursday, September 4, 2008 10:33 AM

      W 1 Reply Last reply
      0
      • J John Ad

        Hi Wamuti, Try using the following line of code if it is a Bound ListBox: this.listBox1.DataSource = null; For Unbound ListBox: this.listBox1.Items.Clear() I hope this would be helpful.

        John Adams ComponentOne LLC. www.componentone.com

        modified on Thursday, September 4, 2008 10:33 AM

        W Offline
        W Offline
        Wamuti
        wrote on last edited by
        #3

        I will get back since im abit far from my codes. Thanx alot.

        Wamuti: Any man can be an island, but islands to need water around them! Edmund Burke: No one could make a greater mistake than he who did nothing because he could do only a little.

        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