By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,143 Members | 1,919 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,143 IT Pros & Developers. It's quick & easy.

Overriding events in an inherited class

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.