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

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.

Invalid nested tag div found, expected closing tag input