C# How to disable focus??
-
Select your button in the form designer. Switch "Properties" to the "Events"-Mode. Then scroll to the "Focus"-Section and give some method name for "Enter". I used "button1_FocusEnter". This will create an empty method in which you put one line: someOtherControl.Focus; You can also prevent users from "tabbing" through your control by setting "TabStop" to false. With the "coded" solution, the button will never keep focus, the someOtherControl will receive Focus instead. That will not prevent anyone from pressing that button, though. If you want users NOT to press a button, disable it. If you set TabStop to false, the control still gets focused if someone presses it. If you combine both ways, the button will never KEEP focus, but users can still press it and trigger it and stuff. Cheers Sebs
-
Select your button in the form designer. Switch "Properties" to the "Events"-Mode. Then scroll to the "Focus"-Section and give some method name for "Enter". I used "button1_FocusEnter". This will create an empty method in which you put one line: someOtherControl.Focus; You can also prevent users from "tabbing" through your control by setting "TabStop" to false. With the "coded" solution, the button will never keep focus, the someOtherControl will receive Focus instead. That will not prevent anyone from pressing that button, though. If you want users NOT to press a button, disable it. If you set TabStop to false, the control still gets focused if someone presses it. If you combine both ways, the button will never KEEP focus, but users can still press it and trigger it and stuff. Cheers Sebs
-
Another, perhaps easier way is to create a button that's not selectable per-se. Create a new class
InertButton
that inheritsButton
. In the c'tor you just add the following line:SetStyle(ControlStyles.Selectable, false);
That's it. Use this
InertButton
exactly the same way you would use a regular button. Regards, mav -
Another, perhaps easier way is to create a button that's not selectable per-se. Create a new class
InertButton
that inheritsButton
. In the c'tor you just add the following line:SetStyle(ControlStyles.Selectable, false);
That's it. Use this
InertButton
exactly the same way you would use a regular button. Regards, mav