473,624 Members | 2,213 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Override Event

Hi,

Is it possible to override an event replacing its EventArgs w/ my own
event? like
this is native event
protected override void OnDropDownClose d(EventArgs e)
{
//code goes here...
}

I created my own EventArgs so I could replace the one on top. Its called
DropDownClosed_ EventHandler. So it should look like this.
protected override void OnDropDownClose d(DropDownClose d_EventHandler e)
{
//code goes here...
}
but it doesn't accept it. If i use this code.
public event DropDownClosed_ EventHandler DropDownClosed;

DropDownClosed_ EventArgs args = new DropDownClosed_ EventArgs();
DropDownClosed( this, args);
after i compiled it, it shows 2 DropDownClosed event one is mine and the
other is native. Is there a way to override the original event so i
could use its name at least to create my own event?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #1
2 4506
Hi Ryan,

Changing the argument list is rather overloading than overriding and I am
not sure overloading is supported for delegates. So I'd just create a second
event with my own EvenArgs type, and I would even name it something like
DropDownClosedE x.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Ryan Joseph So" <ac***********@ hotmail.com> wrote in message
news:Oj******** ******@TK2MSFTN GP15.phx.gbl...
Hi,

Is it possible to override an event replacing its EventArgs w/ my own
event? like
this is native event
protected override void OnDropDownClose d(EventArgs e)
{
//code goes here...
}

I created my own EventArgs so I could replace the one on top. Its called
DropDownClosed_ EventHandler. So it should look like this.
protected override void OnDropDownClose d(DropDownClose d_EventHandler e)
{
//code goes here...
}
but it doesn't accept it. If i use this code.
public event DropDownClosed_ EventHandler DropDownClosed;

DropDownClosed_ EventArgs args = new DropDownClosed_ EventArgs();
DropDownClosed( this, args);
after i compiled it, it shows 2 DropDownClosed event one is mine and the
other is native. Is there a way to override the original event so i
could use its name at least to create my own event?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 16 '05 #2
Thanks Dmitriy but I still have one question. Is it possible to hide the
native event so only my event would show up when i compiled the project?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
12115
by: JPRoot | last post by:
Hi I use the following syntax to have events inherited from base to child classes which works nicely (virtual and override keyword on events). But I am wondering if it is a "supported" way of using events since I never saw it used anywhere in MSDN documentation/samples?! Or it will just break when I upgrade to .NET Framework 2.x in the coming years namespace MyNamespac public delegate void MyDel() public class MyBase public virtual...
8
2886
by: JPRoot | last post by:
Hi M. Jeffrey Tan, Just hopping you didn't forget me? :) Thanks JPRoot ----- \"Jeffrey Tan\" wrote: -----
18
4830
by: bhavin | last post by:
Hi, Can someone point me to some good best practices kind of documentation on use of events compared to method overriding. Ex. In Windows Forms when should i have an event handler for Paint, and when should i override OnPaint? I have to implement added functionality in a child class, and am in two minds .. to have the parent fire an event, or make the method virtual and override in the child. Am hoping some reading with description of...
8
11791
by: Keith Smith | last post by:
Could some one help me a little? I am trying to understand when/where you would ever want to use "protected override..." code such as this. How is this any different from creating a SelectedTextChanged type event? This is an example I found on the web... protected override void OnTextChanged(System.EventArgs e) { try
0
1096
by: DotNetBBK | last post by:
Hi, I am using a custom text box, where I need to override TabSelection, as I have to generate an event and based on that event, I need to do some processing in other class, who is listening to that event. This thing works fine, when I am stopping in the debugger for the event, but as soon as I remove the breakpoint from the event handler method. This doesn't work and even the release version of the software also doesn't work. Following...
8
5483
by: bdeviled | last post by:
I am deploying to a web environment that uses load balancing and to insure that sessions persist across servers, the environment uses SQL to manage sessions. The machine.config file determines how all applications will use sessions and to insure that all application use this method, the session properties cannot be overriden. Within the sessionstate tags, the webadmin (upon my request)r emoved the property for timeout, hoping that...
3
1789
by: Publicjoe | last post by:
OK Folks, I am one confused puppy. Can someone please explain what the difference is and when to use each. I have a form with a button dropped onto it. Without actually doing anything to the button, I next add the following code: protected override void OnKeyDown(KeyEventArgs e) { System.Diagnostics.Debug.WriteLine(e.KeyCode.ToString()); base.OnKeyDown(e);
2
1432
by: Publicjoe | last post by:
OK Try again Can someone please explain what the difference is and when to use each. I have a form with a button dropped onto it. Without actually doing anything to the button, I next add the following code to the form: protected override void OnKeyDown(KeyEventArgs e) { System.Diagnostics.Debug.WriteLine(e.KeyCode.ToString());
4
12006
by: Rob | last post by:
I've constructed a user control inherited from ListView so I can handle and respond to scrolling events (to keep 2 listviews scrolling in sync). My user control includes an Overrides of WndProc (I've attached the code at the end of this mail). Is it possible to 'disable' this override until I need it - it's just when I populate the ListViews this sub is called repeatadly. What I'd like to do is populate the listviews and then 'enable'...
0
8238
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8680
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8624
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8336
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6111
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4082
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1786
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1485
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.