Hi,
I have some Dialogs that I popup and for design purposes, I dont really want to show a “Close” button but still want the functionality of Escape to Cancel.
I created a button that I set Visible to false and set that as the CancelButton for the Dialog. However when I do this, escape to close does not fire.
If I make the button visible, it works as expected.
I have gotten around the issue by just setting the button size to 1 x 1 and no border so it is essentially “invisible”.
I just wanted to check if this was the expected behaviour of an invisible button?
Thanks,
Brayden.
Hi
Not execute code for invisible controls it’s by design and it would be a security issue to execute hidden buttons.
You can easily register an accelerator. See Form.Accelerators collection.
In the sample code atached you can see details
and in the video gif how it works.
The form dialog use Accelerator collection to register the ESC and raise event when the form has focused and trigger a common void triggred also by the button.
Regards and HTH
Please login first to submit.