Posts

Showing posts with the label Delegates

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!

Donate