private void SetCheckBox(System.Windows.Forms.CheckBox cb, bool status) { cb.BeginInvoke(new Action(() => { cb.Checked = status; })); }
private void PerformToggle(SWF.CheckBox checkbox, SWF.CheckState state) { if (checkbox.InvokeRequired == true) { checkbox.BeginInvoke(new PerformToggleDelegate(PerformToggle), new object [] { checkbox, state }); return; } // NOTE: We can count on presence of InvokeOnClick; // it is a protected member of CheckBox. // // This basically simulates a click, which always // raises the Click event, but strangely does not // raise CheckChanged when transitioning to // Indeterminate state. This matches MS behavior. MethodInfo invokeOnClick = typeof(SWF.CheckBox).GetMethod("InvokeOnClick", BindingFlags.NonPublic | BindingFlags.Instance); invokeOnClick.Invoke(checkbox, new object [] { checkbox, EventArgs.Empty }); }
public void SetCheckBoxState(CheckBox anything, bool state) { anything.BeginInvoke((MethodInvoker)delegate { try { anything.Enabled = state; } catch { } }); }