[resolved]how to create an event for enum type value changed?
i creating an user control library , vs 2008, .net framework3.5,
how can i add a event trigger for an enum type?
Code:
public enum period_type { Text, TrackBar };
private period_type period_type_selected;
public period_type Period_Type_Select { get { return period_type_selected; } set { period_type_selected = value; } }
how can i set the event when period_type_selected has changed? is it possible?
thx
chan
Re: how to create an event for enum type value changed?
problem solved.
i added code into the function Period_Type_Select.
chan
Re: how to create an event for enum type value changed?
I assume you could try something like this.
Code:
public period_type Period_Type
{
get { ...... }
set
{
if(value != period_type_selected)
// Fire Enum Event changed here
period_type_selected = value;
}
}
Re: how to create an event for enum type value changed?
You would probably want to change the value first before firing the event just to make sure the value actually gets changed. If you fire the event then your calling code which is essentially unknown to the program until runtime and that code could throw an exception or blow up in some other way and cause the value to not be changed.
Re: how to create an event for enum type value changed?
Quote:
Originally Posted by
RaleTheBlade
You would probably want to change the value first before firing the event just to make sure the value actually gets changed. If you fire the event then your calling code which is essentially unknown to the program until runtime and that code could throw an exception or blow up in some other way and cause the value to not be changed.
Yeah you're right