Dennis,
The following code "simplifies" this concept:
| dim mySelectedEnum as myEnum
|
| 'Display the Enum names in the combo box
| myComboBox.DataSource = [Enum].GetValues(GetType(myEnum))
|
| 'Get the selected Enum
| mySelectedEnum = DirectCast(myComboBox.SelectedItem, myEnum)
Notice the actual bind is the same amount of code, however the get selected
value is significantly simplified.
--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -
http://www.tsbradley.net
| The following code binds an enum to a combo-box and then retrieves the
Enum
| that is selected in the combo-box:
|
| dim mySelectedEnum as myEnum
|
| 'Display the Enum names in the combo box
| myComboBox.DataSource = [Enum].GetNames(GetType(myEnum))
|
| 'Get the selected Enum
| mySelectedEnum = CType([Enum].Parse(GetType(myEnum), _
| myComboBox.SelectedItem.ToString), myEnum)
|
| Hope this helps.
| --
| Dennis in Houston
|
|
| "Nathan" wrote:
|
| > I'd like to use an enumeration as a datasource for a drop-down box. Is
there
| > a way to do this?