How to set focus on button while button is disabled in winform c#?

Viewed 190

I want to set the focus in the button when a button is disabled in the windows form application.

Is there any way to achieve this goal?

Background:

I am making an application that can be used by a blind person so when the button is enabled then on focus screen reader will read of button content but when a button is disabled then not possible to read by screen reader because of the button can not be focused on disabled mode

2 Answers

You can create a custom control and create one propriety into a custom control. using that property to check OnClick need to fire or not.

For Example:

   public class buttonReadonly: Button
   {
       private bool _isReadOnly = false;

       public bool isReadOnly
       {
           get
           {
               return _isReadOnly;
           }
           set
           {
               _isReadOnly = value;
           }
       }

       protected override void OnClick(EventArgs e)
       {
           if (!isReadOnly)
           {
               base.OnClick(e);
           }
       }
       
   }
Related