Converting string to Keys enum value?

  • Thread starter Thread starter Arkion
  • Start date Start date
A

Arkion

Hello!
I'm using XML serialization to store key assignments and came across a
little problem. Is it possible to convert a string, eg. "PageUp" to
equivalent System.Windows.Forms.Keys enumeration value?
 
Here is one option (in VB .NET):

[Enum].Parse(GetType(System.Windows.Forms.Keys), "PageUp", False)

If the string doesn't exist in the enumeration, an exception will be raised.

Hello!
I'm using XML serialization to store key assignments and came across a
little problem. Is it possible to convert a string, eg. "PageUp" to
equivalent System.Windows.Forms.Keys enumeration value?
 
Back
Top