我需要继承 ComboBox 以添加新事件 OnSelectedValueChanging()。当用户尝试更改组合框的当前选定值时,应触发此事件。此事件也应该是可取消的(例如,用户可以在 FormClosing 事件中使用 e.cancel)
public class SUIComboBox : UIComboBox
{
/// <summary>
/// The prevously selected value
/// </summary>
private object _PreviousSelectedValue = null;
public event EventHandler<EventArgs> SelectedValueChanging;
protected virtual void OnSelectedValueChanging(object sender, CancelEventArgs e)
{
var handler = SelectedValueChanging;
handler?.Invoke(sender, e);
}
}
public class SelectedValueChangingEventArgs : CancelEventArgs
{
}