My intent is to reuse the SelectedValueChanged
event inherited from the ComboBox
Class (which, in turn, inherits it from the ListControl
Class)
In the code below: SelectedValueChanged
is tagged with the compiler error shown in the screen shot. I do not intend on hiding
the inherited event, so I do not want to use the new
keyword. I want the classes that I derive from DRT_ComboBox_Abstract to be able to use the inherited event as-is.
How do I define an EventHandler
using an event inherited from a base class? (Or, am I totally off the planet with regard to understanding events?)
Note: "Show Potential Fixes" surrounds public event EventHandler SelectedValueChanged
with #pragma warning disable CS0108
which just disables the warning.
using System;
using System.Windows.Forms;
namespace DRT
{
internal abstract partial class DRT_ComboBox_Abstract : ComboBox
{
//SelectedValueChanged is tagged with the compiler error shown in the screenshot
public event EventHandler SelectedValueChanged;
public DRT_ComboBox_Abstract()
{
InitializeComponent();
}
public void Disable()
{
this.Enabled = false;
}
public void _OnSelectedValueChanged(object sender, System.EventArgs e)
{
this.SelectedValueChanged?.Invoke(sender, e);
}
}
}