Donate

Enable/Disable ToolstripButton Using Delegates (Thread) In C#

Assuming you will access the toolstrip button from another thread, then here's the code on how to enable or disable ToolstripButton using delegates.
delegate void EnableDisableButtonRunDeleg(bool value);  
      private void EnableDisableButtonRun(bool value)  
      {  
        if (tsMenu.InvokeRequired)  
        {  
         this.tsMenu.Invoke(new EnableDisableButtonRunDeleg   
          (EnableDisableButtonRun), value);  
        }  
        else  
        {  
          ToolStripItem ts = tsMenu.Items[0];  
          ((ToolStripButton)ts).Enabled = value;  
        }  
      }
Cheers!

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

How To Insert Or Add Emojis In Microsoft Teams Status Message

Pass GUID As Parameter To Action Using ASP.NET MVC ContribGrid