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 to get combo items

How to get combo items

Scheduled Pinned Locked Moved C#
helptutorial
8 Posts 4 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.
  • R Offline
    R Offline
    ranandbe
    wrote on last edited by
    #1

    Hi all, i have problem with combobox collection items. :^)i need to check all entrys in combo box with foreach, i know the way but i dont know the exact class for combo box items(like ListItem).Thank u. Best Regards, ranandbe. -- modified at 1:20 Wednesday 7th June, 2006

    R M 2 Replies Last reply
    0
    • R ranandbe

      Hi all, i have problem with combobox collection items. :^)i need to check all entrys in combo box with foreach, i know the way but i dont know the exact class for combo box items(like ListItem).Thank u. Best Regards, ranandbe. -- modified at 1:20 Wednesday 7th June, 2006

      R Offline
      R Offline
      rah_sin
      wrote on last edited by
      #2

      try out following for(int i=0;i < comboBox1.Items.Count;i++) { MessageBox.Show(comboBox1.GetItemText(comboBox1.Items[i])); } rahul -- modified at 1:39 Wednesday 7th June, 2006

      R 1 Reply Last reply
      0
      • R rah_sin

        try out following for(int i=0;i < comboBox1.Items.Count;i++) { MessageBox.Show(comboBox1.GetItemText(comboBox1.Items[i])); } rahul -- modified at 1:39 Wednesday 7th June, 2006

        R Offline
        R Offline
        ranandbe
        wrote on last edited by
        #3

        thank u for replying, now i work with the same what you send but i want to know using foreach statement. Thanks & Regards., ranandbe

        R 1 Reply Last reply
        0
        • R ranandbe

          thank u for replying, now i work with the same what you send but i want to know using foreach statement. Thanks & Regards., ranandbe

          R Offline
          R Offline
          rah_sin
          wrote on last edited by
          #4

          i don't think that it is possible to iterate through foreach becouse i didn't found any class for combobox items. rahul

          1 Reply Last reply
          0
          • R ranandbe

            Hi all, i have problem with combobox collection items. :^)i need to check all entrys in combo box with foreach, i know the way but i dont know the exact class for combo box items(like ListItem).Thank u. Best Regards, ranandbe. -- modified at 1:20 Wednesday 7th June, 2006

            M Offline
            M Offline
            MCSD Gandalf
            wrote on last edited by
            #5

            In a combo box the items are just strings so you can do this: foreach (string itm in comboBox1.Items) { MessageBox.Show(itm); } HTH

            S 1 Reply Last reply
            0
            • M MCSD Gandalf

              In a combo box the items are just strings so you can do this: foreach (string itm in comboBox1.Items) { MessageBox.Show(itm); } HTH

              S Offline
              S Offline
              Sean Michael Murphy
              wrote on last edited by
              #6

              MCSD-Gandalf wrote:

              In a combo box the items are just strings...

              Not always true. The Items property is an ObjectCollection because you can stuff whatever you want in the collection, and render the Items yourself in a custom drawing routine. It's usually strings, but not always. Share and enjoy. Sean

              M 1 Reply Last reply
              0
              • S Sean Michael Murphy

                MCSD-Gandalf wrote:

                In a combo box the items are just strings...

                Not always true. The Items property is an ObjectCollection because you can stuff whatever you want in the collection, and render the Items yourself in a custom drawing routine. It's usually strings, but not always. Share and enjoy. Sean

                M Offline
                M Offline
                MCSD Gandalf
                wrote on last edited by
                #7

                Very true. Of course HOPEFULLY if you have stuffed something else in there you know what it is and can write the appropriate foreach loop. And if not I guess you can always treat everything in there as an object and write the foreach loop that way. Guess I need to be a bit clearer around here with all you guru's watching:laugh: ! Thanks! Gandalf

                S 1 Reply Last reply
                0
                • M MCSD Gandalf

                  Very true. Of course HOPEFULLY if you have stuffed something else in there you know what it is and can write the appropriate foreach loop. And if not I guess you can always treat everything in there as an object and write the foreach loop that way. Guess I need to be a bit clearer around here with all you guru's watching:laugh: ! Thanks! Gandalf

                  S Offline
                  S Offline
                  Sean Michael Murphy
                  wrote on last edited by
                  #8

                  MCSD-Gandalf wrote:

                  Guess I need to be a bit clearer around here with all you guru's watching

                  The comment wasn't so much for you; it was intended for people who are less well informed who may read the thread later. I don't usually presume to correct MCSDs. Share and enjoy. Sean

                  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