/// <summary> /// Raises the Removing event. /// </summary> /// <param name="e">A TypedCollectionEventArgs instance containing event data.</param> protected override void OnRemoving(TypedCollectionEventArgs <KryptonContextMenuItemBase> e) { // Must unhook from the change event to prevent memory leak if (e.Item is KryptonContextMenuRadioButton radioButton) { radioButton.CheckedChanged -= OnRadioButtonCheckedChanged; } base.OnRemoving(e); }
/// <summary> /// Raises the Inserted event. /// </summary> /// <param name="e">A TypedCollectionEventArgs instance containing event data.</param> protected override void OnInserted(TypedCollectionEventArgs <KryptonContextMenuItemBase> e) { base.OnInserted(e); // We monitor changes to the checked state of radio buttons if (e.Item is KryptonContextMenuRadioButton radioButton) { radioButton.CheckedChanged += OnRadioButtonCheckedChanged; } }