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. combobox items

combobox items

Scheduled Pinned Locked Moved C#
question
7 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.
  • C Offline
    C Offline
    chindiwo
    wrote on last edited by
    #1

    How do I access the item from the drop down list when I click the button? Chindiwo Jnr. Programmer -----

    M 1 Reply Last reply
    0
    • C chindiwo

      How do I access the item from the drop down list when I click the button? Chindiwo Jnr. Programmer -----

      M Offline
      M Offline
      mav northwind
      wrote on last edited by
      #2

      ComboBox.SelectedItem mav

      C 1 Reply Last reply
      0
      • M mav northwind

        ComboBox.SelectedItem mav

        C Offline
        C Offline
        chindiwo
        wrote on last edited by
        #3

        Mav this a good e.g of what I want to do label1.Text = combobox.SelectedItme. and if I do that, there's errors Chindiwo Programmer -----

        H M 2 Replies Last reply
        0
        • C chindiwo

          Mav this a good e.g of what I want to do label1.Text = combobox.SelectedItme. and if I do that, there's errors Chindiwo Programmer -----

          H Offline
          H Offline
          hooray
          wrote on last edited by
          #4

          in this case just use: label1.Text = combobox.SelectedText;

          C 1 Reply Last reply
          0
          • C chindiwo

            Mav this a good e.g of what I want to do label1.Text = combobox.SelectedItme. and if I do that, there's errors Chindiwo Programmer -----

            M Offline
            M Offline
            mav northwind
            wrote on last edited by
            #5

            That's simple: label1.Text is of type string, combobox.SelectedItem is of type object, that's what the error most likely tells you. Reading (and understanding!) the errors you get is the key to successful programming. Convert the object to string by using ToString() for example. Try:

            if (combobox.SelectedItem != null)
            label1.Text = combobox.SelectedItem.ToString();

            Regards, mav

            C 1 Reply Last reply
            0
            • M mav northwind

              That's simple: label1.Text is of type string, combobox.SelectedItem is of type object, that's what the error most likely tells you. Reading (and understanding!) the errors you get is the key to successful programming. Convert the object to string by using ToString() for example. Try:

              if (combobox.SelectedItem != null)
              label1.Text = combobox.SelectedItem.ToString();

              Regards, mav

              C Offline
              C Offline
              chindiwo
              wrote on last edited by
              #6

              thanx a lot man! It works! Chindiwo Programmer -----

              1 Reply Last reply
              0
              • H hooray

                in this case just use: label1.Text = combobox.SelectedText;

                C Offline
                C Offline
                chindiwo
                wrote on last edited by
                #7

                thanx for your time, but this is how it suppose to be. label103.Text = IncomeCombo.SelectedItem.ToString(); Chindiwo Programmer -----

                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