• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 509
  • Last Modified:

Add whole enum to combobox


how can i add all the items of an enum to a combobox (not having to code each one)

example enum:

Public Enum MP_Maps
   mp_breakout
   mp_toujane
   mp_trainstation
End Enum


now i can do this:

combo1.additem mp_maps.mp_breakout
combo1.additem mp_maps.mp_toujane
combo1.additem mp_maps.mp_trainstation

but when the enum is longer this is quite much work....
0
Mark_FreeSoftware
Asked:
Mark_FreeSoftware
  • 3
  • 3
  • 3
  • +1
1 Solution
 
bruintjeCommented:
Hi Mark_FreeSoftware,
----------

if you use a hidden member in the enum to end counting in a for each loop

this is shown here
http://tinyurl.com/r3rd8

----------
bruintje
share what you know, learn what you don't
0
 
Mark_FreeSoftwareAuthor Commented:

@ bruintje,

can i add the text to the combobox instead of the number?

(i don't have a pc available to try it out now)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
bruintjeCommented:
tried that but i don't think that is going to work that way except for your first comment doing them one by one
it's not an array which will make such a loop possible

the for i to x loop in the links above will only doing the numbers
0
 
basicinstinctCommented:
Sorry, am I missing something here?  What's to stop you doing this?

For i = mp_breakout to mp_trainstation
      combo1.additem mp_maps.i
Next
0
 
bruintjeCommented:
did not test that but if that works you got the answer :)
0
 
Mark_FreeSoftwareAuthor Commented:
>>Sorry, am I missing something here?  What's to stop you doing this?

this error:
method or data member not found


vb doesnt like the ".i"
0
 
basicinstinctCommented:
Well I'm still not 100% sure what you are trying to do...  Is this it?

For i = mp_breakout to mp_trainstation
     combo1.additem i
Next
0
 
basicinstinctCommented:
When you do it manually like this:

  combo1.additem mp_maps.mp_breakout
  combo1.additem mp_maps.mp_toujane
  combo1.additem mp_maps.mp_trainstation

What actually would be the items displayed in the combobox at runtime?
0
 
Mark_FreeSoftwareAuthor Commented:

>> What actually would be the items displayed in the combobox at runtime?

the numbers also.


basically what i want is this:

all the names added to the combobox, so i can choose one.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 3
  • 3
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now