Hi there,
Im trying to implement a way to set the shortcuts defined by the user.
Im using NHibernate and my model class returns me fields in Keys type (Keys is an Enum that contains the name of the keys. example: Keys.F1)
I have implemented it in a static way and the code is the following:
Now I have a form and the user redefined these shortcuts and I dont know how to do to set them. To be more specific:
I know that the SWITCH statment only accepts constants but i didnt figure out a way to do this.
I hope you can help me
Fernando Mello
Im trying to implement a way to set the shortcuts defined by the user.
Im using NHibernate and my model class returns me fields in Keys type (Keys is an Enum that contains the name of the keys. example: Keys.F1)
I have implemented it in a static way and the code is the following:
Code:
internal void set_shortcuts (KeyEventArgs e) { switch (e.KeyCode) { case Keys.F1: this.button_save.PerformClick(); break; case Keys.F2: this.button_cancel.PerformClick(); break; } }
Code:
internal void set_shortcuts (KeyEventArgs e) { Keys save_shortcut = Shortcuts.load("save_button"); Keys cancel_shortcut = Shortcuts.load("cancel_button"); switch (e.KeyCode) { case save_shortcut: this.button_save.PerformClick(); break; case cancel_shortcut: this.button_cancel.PerformClick(); break; } }
I hope you can help me
Fernando Mello
Comment