Is is possible to make the underlining hotkey always visible on my controls without having to press the Alt key in a Windows form with Visual Studio - C#?
I only have a certain time when I need the controls of the form to be always underlined with the "_" under a character. So it would be good to have just the code to do it.
I could have the setting for Windows to always show underlining of shortcuts and hotkeys, but I only need it to happen a certain time.
Assuming you are using WinForms, you should be able to rely on the underlying Win32 mechanism. And that is the
WM_UPDATEUISTATE
message. The documentation says:So you can send the message to the handle of the top-level window. You need to pass
UIS_CLEAR
for the low-order word ofwParam
andUISF_HIDEACCEL
for the high-order word ofwParam
.Here is some rather crude sample code. Bear in mind that my C# expertise is very limited.