R
Rene
Say that I create a combobox with pull down items that map directly to an
enum. For example the dropdown items could be "Up", "Down", "Left" and
"Right" and the enum could be declare as: public enum DirectionEnum {Up,
Down, Left, Right};
If I needed to get an enum reference based on the dropdown selection, as of
today I would do the following:
DirectionEnum myEnum; // Declare enum.
If(someCombobox.Text == "Up") myEnum == DirectionEnum.Up;
If(someCombobox.Text == "Down") myEnum == DirectionEnum.Down;
etc...
What I would like to do is something like my make believe following code:
myEnum = DirectionEnum.GetEnumByName(someCombobox.Text);
Is there any way to achieve something like the code above?
Thank you.
enum. For example the dropdown items could be "Up", "Down", "Left" and
"Right" and the enum could be declare as: public enum DirectionEnum {Up,
Down, Left, Right};
If I needed to get an enum reference based on the dropdown selection, as of
today I would do the following:
DirectionEnum myEnum; // Declare enum.
If(someCombobox.Text == "Up") myEnum == DirectionEnum.Up;
If(someCombobox.Text == "Down") myEnum == DirectionEnum.Down;
etc...
What I would like to do is something like my make believe following code:
myEnum = DirectionEnum.GetEnumByName(someCombobox.Text);
Is there any way to achieve something like the code above?
Thank you.