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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top