Access Enumeration Value

Mondeo

Centurion
Joined
Nov 10, 2006
Messages
128
Location
Sunny Lancashire
Hi,

Got an enumeration which i've iterated through and added its members to a combobox.

Visual Basic:
Dim s As New Nevron.UI.WinForm.Controls.ColorScheme
Dim schemes As Array
schemes = system.Enum.GetValues(GetType(Nevron.UI.WinForm.Controls.ColorScheme))
        Dim scheme As Nevron.UI.WinForm.Controls.ColorScheme
        For Each scheme In schemes
            cboPalletteSelect.Items.Add(scheme)
        Next

When the user selects a scheme I need to store the integer value of the enum in my database, but how do I access it?

cboPalletteSelect.SelectedItem only returns a string, how to I get the underlying index of the selected enum?

Thanks
 
SelectedIndex and SelectedValue

Do you need the selected value's index, or the actual enum value? To retrieve the index you can use the SelectedIndex property. To retrieve the enum value you can use the SelectedValue property, or cast the SelectedItem to an Integer - the item is probably not a string but an instance of the ColorScheme type.

Good luck :cool:
 
Back
Top