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. Visual Basic
  4. How to add new item to combo box?

How to add new item to combo box?

Scheduled Pinned Locked Moved Visual Basic
tutorialquestion
6 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
    cheeken2u
    wrote on last edited by
    #1

    How to add new item to combo box at code behind ?

    Best regards, Chee ken

    J 1 Reply Last reply
    0
    • C cheeken2u

      How to add new item to combo box at code behind ?

      Best regards, Chee ken

      J Offline
      J Offline
      Johan Hakkesteegt
      wrote on last edited by
      #2

      Hi Chee ken, Try ComboBox1.Items.Add("blablabla") Good luck, Johan

      My advice is free, and you may get what you paid for.

      C A 2 Replies Last reply
      0
      • J Johan Hakkesteegt

        Hi Chee ken, Try ComboBox1.Items.Add("blablabla") Good luck, Johan

        My advice is free, and you may get what you paid for.

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

        Thanks for reply. The item add sucessfully. Can i ask one more question, how to assign the value for it ? or its value is -1? And why it not show while the program load ( it locate at the second item at the drop down list and the first one is blank ) ? thanks.

        Best regards, Chee ken

        J 1 Reply Last reply
        0
        • C cheeken2u

          Thanks for reply. The item add sucessfully. Can i ask one more question, how to assign the value for it ? or its value is -1? And why it not show while the program load ( it locate at the second item at the drop down list and the first one is blank ) ? thanks.

          Best regards, Chee ken

          J Offline
          J Offline
          Johan Hakkesteegt
          wrote on last edited by
          #4

          The .Add method will usually put the value at the end of the list. If you want to add the item at a specific point in the list, use: dim YourIndexNumber as Integer 'Determine here at what position you want to insert your value, 'and assign this position's index number to YourIndexNumber. 'Index starts at 0 ComboBox1.Items.Insert(YourIndexNumber , "blablabla") I am sorry, but I don't quite understand the second part of your question. -- modified at 4:29 Friday 9th February, 2007

          My advice is free, and you may get what you paid for.

          1 Reply Last reply
          0
          • J Johan Hakkesteegt

            Hi Chee ken, Try ComboBox1.Items.Add("blablabla") Good luck, Johan

            My advice is free, and you may get what you paid for.

            A Offline
            A Offline
            alicris
            wrote on last edited by
            #5

            And what hapend when combobox source is a table?. Necesary you must insert into that table the new item then. In addition you must refresh the combobox after. ¿What do you think?. Thanks.

            J 1 Reply Last reply
            0
            • A alicris

              And what hapend when combobox source is a table?. Necesary you must insert into that table the new item then. In addition you must refresh the combobox after. ¿What do you think?. Thanks.

              J Offline
              J Offline
              Johan Hakkesteegt
              wrote on last edited by
              #6

              It depends on two things: 1. do you use databinding between the table and combobox? If you do, then yes, you would need to insert the entry into the table and refresh the databinding. If you fill the combobox with your own code though, and just use the table as a source, you could insert the entry straight into the combobox. 2. do you need the entry for your combobox to be saved into the table, or does the table only contain the basic entries, and are new entries just temporary in nature? If you need the new entries to be saved, use databinding, and write the entry into the table, rather than to the combobox. If they are only temporary, write them straight to the combobox, and do not use databinding. Is that what you meant? Johan

              My advice is free, and you may get what you paid for.

              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