Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Question, please, how to assign keyboard shortcuts, when I press f1 the form opens, and when I press f1 again the form closes for the same function with one key.


What I have tried:

Thank you very much for your efforts
Posted
Comments
Graeme_Grant 6-Jul-22 3:34am    
Are you talking Winform, WPF, Xamarin, Maui, Blazor, or Asp.net?
OriginalGriff 6-Jul-22 3:48am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with - we get no other context for your project.
Imagine this: you go for a drive in the country, but you have a problem with the car. You call the garage, say "it broke" and turn off your phone. How long will you be waiting before the garage arrives with the right bits and tools to fix the car given they don't know what make or model it is, who you are, what happened when it all went wrong, or even where you are?

That's what you've done here. So stop typing as little as possible and try explaining things to people who have no way to access your project!

Use the "Improve question" widget to edit your question and provide better information.
[no name] 6-Jul-22 12:16pm    
F1 is usually reserved for "Help" (screens); ctrl-F4 is used for closing the current window; and "opening" a form depends on the context: e.g. popping a form on the selected row of a grid (say, F2 - edit).

http://csharp.net-informations.com/gui/key-press-cs.htm
Member 15627495 7-Jul-22 23:25pm    
use a global var like "currentForm"

and write a function 'toggleForm"
when you press F1 :
fill "currentForm" with the new current Windows
open the new current Windows

and when closing this Windows by f1 or else, unload the global; var



you can create an event handler in the new form to show,

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900