P
pkiddie
Hi!
Im having real issues understanding delegates/events in .NET v1, and was
hoping someone could shed some light on where I'm not quite understanding.
I've got this piece of code in a base user control, which i've called
'PropertyPanel'. In it is the following code:
public delegate void EventHandler(object sender, EventArgs e);
public event EventHandler AppliedProperties;
private void buttonOK_Click(object sender, System.EventArgs e)
{
EventHandler handler = AppliedProperties;
EventArgs ex = new EventArgs();
if (ValidateForm())
{
if (handler!=null)
{
handler(this, ex);
}
}
}
Now what I'd like to do is to derive from my base user control several other
property panels, but still hook to my AppliedProperties event handler within
the main form, which will fire from a specific implementation within the
derived class, for example by:
(in the main form)
PropertyPanel myPropertyPanel;
myPropertyPanel = new NodePropertyPane();
myPropertyPanel.AppliedProperties += new EventHandler(this.Test);
OR myPropertyPanel = new LinkPropertyPane();
myPropertyPanel.AppliedProperties += ....
Does anyone know or can give me advice how to best go about this?
Any help would be greatly appreciated,
Paul
Im having real issues understanding delegates/events in .NET v1, and was
hoping someone could shed some light on where I'm not quite understanding.
I've got this piece of code in a base user control, which i've called
'PropertyPanel'. In it is the following code:
public delegate void EventHandler(object sender, EventArgs e);
public event EventHandler AppliedProperties;
private void buttonOK_Click(object sender, System.EventArgs e)
{
EventHandler handler = AppliedProperties;
EventArgs ex = new EventArgs();
if (ValidateForm())
{
if (handler!=null)
{
handler(this, ex);
}
}
}
Now what I'd like to do is to derive from my base user control several other
property panels, but still hook to my AppliedProperties event handler within
the main form, which will fire from a specific implementation within the
derived class, for example by:
(in the main form)
PropertyPanel myPropertyPanel;
myPropertyPanel = new NodePropertyPane();
myPropertyPanel.AppliedProperties += new EventHandler(this.Test);
OR myPropertyPanel = new LinkPropertyPane();
myPropertyPanel.AppliedProperties += ....
Does anyone know or can give me advice how to best go about this?
Any help would be greatly appreciated,
Paul