473,396 Members | 2,093 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Overriding events in an inherited class

Hi,

I've inherited the XmlDocument class to include some custom methods that I
want to use on a particular XML file.

I need to know whether the document has changed since being loaded, and I
wanted to be clever and hook up to the events that are already defined in
the XmlDocument class (i.e. NodeChanged, NodeInserted).

I had presumed I would simply be able to override them, however I cannot
seem to either find the syntax for this, or any exact resolution to this
question.

My current solution is to attach custom handlers to the base classes
events....

this.NodeChanged += new XmlNodeChangedEventHandler(MyNodeChangedEvent);

internal void MyNodeChangedEvent(Object src, XmlNodeChangedEventArgs args)
{
this.IsDirty = true;
}

Any help gratefully appreciated.

Robert

Nov 15 '05 #1
1 1625
You can hook events by overriding the On... methods in the class and
providing your own logic. If you do this, it is important that you call the
On... method of the parent class so that the events will be fired after the
methods have been called.
"Robert" <ro*@rob.com> wrote in message
news:8s**************@newsfe3-win.server.ntli.net...
Hi,

I've inherited the XmlDocument class to include some custom methods that I
want to use on a particular XML file.

I need to know whether the document has changed since being loaded, and I
wanted to be clever and hook up to the events that are already defined in
the XmlDocument class (i.e. NodeChanged, NodeInserted).

I had presumed I would simply be able to override them, however I cannot
seem to either find the syntax for this, or any exact resolution to this
question.

My current solution is to attach custom handlers to the base classes
events....

this.NodeChanged += new XmlNodeChangedEventHandler(MyNodeChangedEvent);

internal void MyNodeChangedEvent(Object src, XmlNodeChangedEventArgs args)
{
this.IsDirty = true;
}

Any help gratefully appreciated.

Robert

Nov 15 '05 #2

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

Similar topics

8
by: Edward Diener | last post by:
Is it possible for a derived class to override a property and/or event of its base class ?
0
by: Ian | last post by:
I've got this problem with overriding attributes on an inheritance chain where the XmlSerializer is concerned. For example: public class A { private string aWord = String.Empty(); public...
7
by: Opa | last post by:
Hi, I have a class (ClassB) that inherits from another class (ClassA) which has a delegate and event. I can see the events from ClassA in an intance object I create of ClassB. I also...
17
by: Bob Weiner | last post by:
What is the purpose of hiding intead of overriding a method? I have googled the question but haven't found anything that makes any sense of it. In the code below, the only difference is that...
10
by: Chad Miller | last post by:
I currently have a base form that I inherit. The base for has a custom event. The event will not raise threw the inherited form. I was wondering if events work threw inheritance or should I use...
2
by: MuZZy | last post by:
Hi, Consider i have this code: // --------------------------------------------------------------------- public delegate void DoSearchEventHandler(Form f, DoSearchEventArgs e); public class...
12
by: Robert W. | last post by:
This question concerns something I'm trying to do with the CF but it's really a generic C# question. With the Compact Framework, one can't add a radio button with a long label because the labels...
8
by: yashwant pinge | last post by:
#include<iostream> using namespace std; class base { public: void display() { } };
10
by: r035198x | last post by:
The Object class has five non final methods namely equals, hashCode, toString, clone, and finalize. These were designed to be overridden according to specific general contracts. Other classes that...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...

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.