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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. how to insert listbox items in to array object..?

how to insert listbox items in to array object..?

Scheduled Pinned Locked Moved C#
csharpdata-structurestutorialquestion
5 Posts 3 Posters 1 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.
  • S Offline
    S Offline
    sacr83
    wrote on last edited by
    #1

    hi all,,, How i insert ListBox items to Array in c#..?

    CheeN

    G realJSOPR 2 Replies Last reply
    0
    • S sacr83

      hi all,,, How i insert ListBox items to Array in c#..?

      CheeN

      G Offline
      G Offline
      Gareth H
      wrote on last edited by
      #2

      sacr83, Does this help?

      object[] listBoxObjects = new object[listBox.Items.Count];
      listBox.Items.CopyTo(listBoxObjects, 0);

      Regards, Gareth. (FKA gareth111)

      1 Reply Last reply
      0
      • S sacr83

        hi all,,, How i insert ListBox items to Array in c#..?

        CheeN

        realJSOPR Offline
        realJSOPR Offline
        realJSOP
        wrote on last edited by
        #3

        I have to say - this is easily found using google, or even MSDN. Try working it out yourself instead of relying on other people to do your coding for you.

        string[] listItems = new string[this.listbox.items.count];
        for (int i = 0; i < this.listbox.Items.count; i++)
        {
        listItems[i] = this.listbox.Items[i];
        }

        "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
        -----
        "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

        S 1 Reply Last reply
        0
        • realJSOPR realJSOP

          I have to say - this is easily found using google, or even MSDN. Try working it out yourself instead of relying on other people to do your coding for you.

          string[] listItems = new string[this.listbox.items.count];
          for (int i = 0; i < this.listbox.Items.count; i++)
          {
          listItems[i] = this.listbox.Items[i];
          }

          "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
          -----
          "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

          S Offline
          S Offline
          sacr83
          wrote on last edited by
          #4

          Mr John Simmons.. Thank you very much for your help.really it works.really thank you.

          CheeN

          realJSOPR 1 Reply Last reply
          0
          • S sacr83

            Mr John Simmons.. Thank you very much for your help.really it works.really thank you.

            CheeN

            realJSOPR Offline
            realJSOPR Offline
            realJSOP
            wrote on last edited by
            #5

            Vote my response.

            "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
            -----
            "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

            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