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. .NET (Core and Framework)
  4. About ComboBox re-population

About ComboBox re-population

Scheduled Pinned Locked Moved .NET (Core and Framework)
questioncsharpdotnetdata-structures
4 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.
  • H Offline
    H Offline
    Hurricane3000
    wrote on last edited by
    #1

    Hi all, I have a little question about a ComboBox: When program start, such ComboBox is automatically populated with 15 Items that I specified in developing time in the ComboBox Items Collection property. During the running, such Combo can be cleared and re-populate with another set of items(variable values). Is there a way (in VB .Net Framework) to restore back (reset) the Combo with original set of Items with a single instruction, without the need to store original values in an array and re-populate items one by one? Thanks.

    L 1 Reply Last reply
    0
    • H Hurricane3000

      Hi all, I have a little question about a ComboBox: When program start, such ComboBox is automatically populated with 15 Items that I specified in developing time in the ComboBox Items Collection property. During the running, such Combo can be cleared and re-populate with another set of items(variable values). Is there a way (in VB .Net Framework) to restore back (reset) the Combo with original set of Items with a single instruction, without the need to store original values in an array and re-populate items one by one? Thanks.

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      No, the items you entered in Visual Designer end up in the InitializeComponents() method; if you were to call that again, it would recreate all your initial Controls, something one seldom wants. I would: - not populate them with Designer; - create a simple method that populates the ComboBox list; - call it in the constructor (right after the call to InitializeComponents); - call it again whenever you feel you have to. :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


      I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
      [The QA section does it automatically now, I hope we soon get it on regular forums as well]


      H 1 Reply Last reply
      0
      • L Luc Pattyn

        No, the items you entered in Visual Designer end up in the InitializeComponents() method; if you were to call that again, it would recreate all your initial Controls, something one seldom wants. I would: - not populate them with Designer; - create a simple method that populates the ComboBox list; - call it in the constructor (right after the call to InitializeComponents); - call it again whenever you feel you have to. :)

        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


        I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
        [The QA section does it automatically now, I hope we soon get it on regular forums as well]


        H Offline
        H Offline
        Hurricane3000
        wrote on last edited by
        #3

        Thanks Luc!

        L 1 Reply Last reply
        0
        • H Hurricane3000

          Thanks Luc!

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          You're welcome. :)

          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


          I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
          [The QA section does it automatically now, I hope we soon get it on regular forums as well]


          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