public CheckedListBoxControl() { InitializeComponent(); listView1.ItemSelectionChanged += (sender, args) => { ItemCheck?.Invoke(this, new ItemCheckEventArgs(args.ItemIndex, CheckState.Checked, CheckState.Unchecked)); }; }
private void item_CheckStateChanged(object sender, EventArgs e) { if (!_handleEvents || (!(sender is CheckBox))) { return; } var checkBox = (CheckBox)sender; if ((checkBox.Tag is InternalItem) && checkBox.Enabled) { var item = (InternalItem)checkBox.Tag; ItemCheckEventArgs eventArgs; int itemIndex = _itemList.IndexOf(item); if (checkBox.CheckState == CheckState.Checked) { eventArgs = new ItemCheckEventArgs( itemIndex, CheckState.Checked, CheckState.Unchecked); } else { eventArgs = new ItemCheckEventArgs( itemIndex, CheckState.Unchecked, CheckState.Checked); } if (ItemCheck != null) { try { _handleEvents = false; ItemCheck.Invoke(this, eventArgs); // Note: client might changed NewValue: checkBox.CheckState = eventArgs.NewValue; } finally { _handleEvents = true; } } } }
private void listBox_ItemCheck(object sender, ItemCheckEventArgs e) { if (!manuallyFired) { // Force the update of the checkeditems try { manuallyFired = true; SetItemCheckState(e.Index, e.NewValue); } finally { manuallyFired = false; } // Update the combobox's text displayText = GetTextValue(); Invalidate(); ItemCheck?.Invoke(sender, e); } }
internal void OnItemCheck(object sender, ItemCheckEventArgs e) { ItemCheck?.Invoke(sender, e); }
/// <summary> /// Trigger the ItemCheck event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnItemCheck(object sender, ItemCheckEventArgs e) => ItemCheck?.Invoke(this, e);
protected virtual void OnItemCheck(ItemCheckEventArgs e) => ItemCheck?.Invoke(this, e);