private void SetCheckboxState(int index, BoolOutput boolOutput) { CheckState checkState = CheckState.Indeterminate; if (boolOutput.Enabled) { checkState = boolOutput.Value ? CheckState.Checked : CheckState.Unchecked; } _bInternalSelect = true; checkedListBox.SetItemCheckState(index, checkState); _bInternalSelect = false; }
void OnBoolOutput_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (InvokeRequired) { this.BeginInvoke(_delPropChanged, new object[] { sender, e }); return; } BoolOutput boolOutput = sender as BoolOutput; int index = checkedListBox.Items.IndexOf(boolOutput); if (index >= 0) { SetCheckboxState(index, boolOutput); } }
private void OnItemCheck(object sender, ItemCheckEventArgs e) { if (_bInternalSelect) { return; } int index = e.Index; if (index >= 0 && e.NewValue != CheckState.Indeterminate) { BoolOutput boolOutput = checkedListBox.Items[index] as BoolOutput; if (boolOutput != null) { bool newVal = e.NewValue == CheckState.Checked; // checkedListBox.GetItemChecked(index); bool oldVal = e.CurrentValue == CheckState.Checked; // boolOutput.Value; boolOutput.Set(newVal); U.LogChange(string.Format("BoolOutput '{0}' changed from {1} to {2}", boolOutput.Name, oldVal, newVal)); } else { U.LogError(string.Format("BoolOutput is null for index '{0}'", index)); } } }