Example #1
0
 public void SetControlEnabled(Control control, bool val)
 {
     if (control.InvokeRequired)
     {
         SetControlEnabledCallback d = SetControlEnabled;
         try
         {
             Invoke(d, new object[] { control, val });
         }
         catch (Exception) { }
     }
     else
     {
         control.Enabled = val;
     }
 }
Example #2
0
 /// <summary>
 /// Enable or disable a control
 /// </summary>
 /// <param name="container">The control that contains the control to change</param>
 /// <param name="control">The control to change</param>
 /// <param name="val">True to enable, false to disable</param>
 public static void SetControlEnabled(Control container, Control control, bool val)
 {
     if (container == null || control == null)
     {
         return;
     }
     if (container.InvokeRequired)
     {
         SetControlEnabledCallback d = SetControlEnabled;
         try
         {
             container.Invoke(d, new object[] { container, control, val });
         }
         catch { }
     }
     else
     {
         control.Enabled = val;
     }
 }
Example #3
0
 private void SetControlEnabled(Boolean flag, Control ctr)
 {
     // InvokeRequired required compares the thread ID of the
     // calling thread to the thread ID of the creating thread.
     // If these threads are different, it returns true.
     if (ctr.InvokeRequired)
     {
         SetControlEnabledCallback d = new SetControlEnabledCallback(SetControlEnabled);
         this.Invoke(d, new object[] { flag, ctr });
     }
     else
     {
         ctr.Enabled = flag;
     }
 }