示例#1
0
 public CheckedListBoxControl()
 {
     InitializeComponent();
     listView1.ItemSelectionChanged +=
         (sender, args) => {
         ItemCheck?.Invoke(this, new ItemCheckEventArgs(args.ItemIndex, CheckState.Checked, CheckState.Unchecked));
     };
 }
示例#2
0
        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;
                    }
                }
            }
        }
示例#3
0
        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);
 }
示例#5
0
 /// <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);
示例#6
0
 protected virtual void OnItemCheck(ItemCheckEventArgs e) => ItemCheck?.Invoke(this, e);