D
Dom
I'm teaching myself how to write a usercontrol, and how to raise
events within the control. Some questions came up. Let's say I the
event is called "Flyover", and everybody knows what is meant by
FlyoverEventArgs and OnFlyover.
1. When the event is to be raised, as I understand it, I do not raise
it directly. Instead I call a procedure "OnFlyover (new
FlyoverEventArgs (...))". Then I write the procedure called
"OnFlyover" which then does nothing but raise the event -- "Flyover
(this, e)". What is the purpose of "OnFlyover"? It seems to be
nothing but a link in the chain. It seems that instead of calling
this, I can just raise the event itself. Is it only to allow other
users to override it?
2. When I write FlyoverEventArgs, I always get an error about
accessibility, which can only be corrected if I make the class
"public". I thought "public" was the default for a class. Even the
IDE, when it creates a stub, does not insert the word "public".
3. Once, when I wrote FlyoverEventArgs, I forgot that it was supposed
to extend the class "EventArgs". But nothing went wrong. Why are you
told to extend "EventArgs"?
All things considered, it seems that the IDE should have a special
insert for "EventArgs" that includes the word "public" and the
extension of "EventArgs" automatically in the stub.
events within the control. Some questions came up. Let's say I the
event is called "Flyover", and everybody knows what is meant by
FlyoverEventArgs and OnFlyover.
1. When the event is to be raised, as I understand it, I do not raise
it directly. Instead I call a procedure "OnFlyover (new
FlyoverEventArgs (...))". Then I write the procedure called
"OnFlyover" which then does nothing but raise the event -- "Flyover
(this, e)". What is the purpose of "OnFlyover"? It seems to be
nothing but a link in the chain. It seems that instead of calling
this, I can just raise the event itself. Is it only to allow other
users to override it?
2. When I write FlyoverEventArgs, I always get an error about
accessibility, which can only be corrected if I make the class
"public". I thought "public" was the default for a class. Even the
IDE, when it creates a stub, does not insert the word "public".
3. Once, when I wrote FlyoverEventArgs, I forgot that it was supposed
to extend the class "EventArgs". But nothing went wrong. Why are you
told to extend "EventArgs"?
All things considered, it seems that the IDE should have a special
insert for "EventArgs" that includes the word "public" and the
extension of "EventArgs" automatically in the stub.