About ComboBox re-population
-
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.
-
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.
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]
-
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]
Thanks Luc!
-
Thanks Luc!
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]