Usuário com melhor resposta
Use Hotkey (F1,F2 ...) in c#

Pergunta
-
Hello everybody I'm starting a new project and would like to know how
I use the hotkeys (F1-F2) to open other forms different.
Initially I used only to test this code:private void Form1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyData==Keys.F1) MessageBox.Show("yesye"); } private void Form1_Load(object sender, EventArgs e) { } private void Form1_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar=='a') MessageBox.Show("yesye"); }
but unlike what happened with other other projects where I tested this code on my newproject did not work.
The only difference in the project that the code worked and what did not work on the project that was used in a MenuStrip and the other not.
Respostas
-
Change Form property KeyPreview to True.
Bruno Ferreira de Souza
MSP - Microsoft Student Partner
MCTS .NET Framework - Windows Applications
www.maestrodotnet.com.br
@BrunoMaestro- Sugerido como Resposta AndreAlvesLimaModerator sexta-feira, 25 de março de 2011 16:29
- Marcado como Resposta AndreAlvesLimaModerator quinta-feira, 31 de março de 2011 17:05
-
Other interesting way of processing keystrokes is overriding the ProcessCmdKey in the Form's class.
I used this approach recently and I liked the final result.
Regards,
Eric
- Sugerido como Resposta AndreAlvesLimaModerator sexta-feira, 25 de março de 2011 16:29
- Marcado como Resposta AndreAlvesLimaModerator quinta-feira, 31 de março de 2011 17:05
Todas as Respostas
-
Change Form property KeyPreview to True.
Bruno Ferreira de Souza
MSP - Microsoft Student Partner
MCTS .NET Framework - Windows Applications
www.maestrodotnet.com.br
@BrunoMaestro- Sugerido como Resposta AndreAlvesLimaModerator sexta-feira, 25 de março de 2011 16:29
- Marcado como Resposta AndreAlvesLimaModerator quinta-feira, 31 de março de 2011 17:05
-
Other interesting way of processing keystrokes is overriding the ProcessCmdKey in the Form's class.
I used this approach recently and I liked the final result.
Regards,
Eric
- Sugerido como Resposta AndreAlvesLimaModerator sexta-feira, 25 de março de 2011 16:29
- Marcado como Resposta AndreAlvesLimaModerator quinta-feira, 31 de março de 2011 17:05
-
Prezado,
Por favor, pedimos para que sejam postadas somente questões em português nos fóruns da MSDN em PT-BR...
Obrigado pelo apoio...
André Alves de Lima
Microsoft MVP - Client App Dev
Visite o meu site: http://www.andrealveslima.com.br
Me siga no Twitter: @andrealveslima