0

Hello, I design a form that use keydown event such as F1, F2, F3 and so on. The form have access right according to the user logging in. If user is an admin then the user will have the right to access all the form. However, if the user is a normal user then the user will only have access to certain form only. For example, to open Form1, user can press button F1 to open the form. How can i disable it if user don't have the right to access the form?

Thank you.

2
Contributors
1
Reply
2
Views
10 Years
Discussion Span
Last Post by khanhtrung
0

Hi.
In the form's KeyDown event ,we has an object e as type System.Window.Form.KeyEventArgs.We could use this object to check what key is pressed,so doing correlative work.

private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
             switch (e.KeyCode)
            {
                case Keys.F1: //do admin work here
                    break;
                case Keys.F2: // do normal user work here
                    break;
                //.........
            }
        }

Have a nice day.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.