-
September 24th, 2009, 11:30 PM
#1
[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
Last edited by Chan1314; September 27th, 2009 at 10:25 PM.
Reason: resolved
-
September 24th, 2009, 11:40 PM
#2
Re: how to create an event for enum type value changed?
problem solved.
i added code into the function Period_Type_Select.
chan
-
September 25th, 2009, 10:00 AM
#3
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;
}
}
-
September 25th, 2009, 11:00 AM
#4
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.
R.I.P. 3.5" Floppy Drives
"I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones." - Albert Einstein
-
September 25th, 2009, 11:01 AM
#5
Re: how to create an event for enum type value changed?
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|