I would like to ask how to make custom EventArgs for existing event handler.
Lets say, that I have NumericUpDown numericUpDown
control and I want handler for its OnValueChanged
event. Double clicking to ValueChanged
in visual studio makes snippet like this
private void numericUpDown_ValueChanged(object sender, EventArgs e)
{
}
However, I'd like to know how it was changed (like +5, -4.7), but plain EventArgs
does not have this information. Maybe Decimal change = Value - Decimal.Parse(Text)
would do the trick (because of delayed text change), but that's ugly way and may not work every single time.
I guess I should make my own EventArgs like this
class ValueChangedEventArgs : EventArgs
{
public Decimal Change { get; set; }
}
and then somehow override NumericUpDown.OnValueChanged
event to generate my EventArgs with proper information.