Dear all,
WinForms 10.3: we have modal form called with
.....form.ShowDialog() == DialogResult.Ok;
and the form contains UltraButton instances for Ok and Cancel. For some strange reason, pressing ESC was not closing the form when the Cancel button was set to the CancelButton property of the form. So my developer played around and found that if AcceptsFocus is set to true for the Cancel button, the ESC keypress closed the window, but not if AcceptsFocus is set to false.
The reason for disabling this that we do not want to have the focus border around the cancel button immediatley after startup (prevent the thick border there).
But even if we have to just make a workaround and manually shift the focus upon activation, shouldn´t be the ESC button bound in any way to the CancelButton property in such a way that it does not need to have the focus?
Thanks and regards Florian
Hello Florian,
When a form is shown, focus is automatically given to a control based on the TabStop property. It may be a simpler workaround to change the TabStop property of your OK button so that it is a smaller value than the TabStop property of the Cancel button.
It is possible to disable the thick blue border around the button by setting the button's ShowOutline property to false. You can also disable the focus rectangle by setting the button's ShowFocusRect property to false. Note that if you disable both properties, the user will have no indication that the button has focus, and may become confused.
I will follow up with you on the cancel button functionality.
Dear Mike,
thanks for your reply. Yes we have tried your suggestions, in fact I think you mean to use the TabIndex property for this. You are right that disabling the indication may be not what we want.
Still we would like to know why AcceptsFocus blocks the accelerator key binding for the ESC key. Thanks for looking into this.
regards Florian
We have confirmed that this is a bug and we have logged it in our system. The issue number is 66459.