Hooking into Property Events in the .NET IDE

  • Thread starter Thread starter Pertti Karjalainen
  • Start date Start date
P

Pertti Karjalainen

I am a bit of a newbie with .NET. I was wondering if
someone could explain or at least point me to a direction
that would help me do something like this while
developing an application in the .NET IDE (I use C#):

- I select a BindingSource proeprty
- Property Change event is fired, and I hook into it to
populate other properties, such as ReadOnly, ToolTip,
etc. from an external source.

Thank you very much!
 
hi !

first you need to declare a delegate for the event :

public delegate void MyPropChangedEventType (object sender, EventArgs e);

(you may use other params, if not use the eventHandler because, it is the
same and you don't need delegate.
second your class msut have an event of the délegate type, and you have to
throw the event in the property.

YourClass
{
public event MyPropChangedEventType PropChangedEvent;

public int MyProp
{
set
{
// do what you have to do
// fire the event
if(this.PropChangedEvent != null) // if there is listener of the event
this.PropChangedEvent(this, EventArgs.Empty); // the params are the same
as the delegate!!
// may be you can directly populate here, i don't know your
possibilities.
}
}
}

then somewhere else in your program you need to create an instance of the
class, and create a listenner to the event:

CallerClass
{
public void method()
{
YourClass A = new YourClass();
// add a listener of the event
A.PropChangedEvent += new MyPropChangedEventType(this.Listener);

}
public void Listener (object sender, EventArgs e) // same declaration as
the delegate
{
// what you have to do when catching the event, like populate something
// or call to ((YourClasse)sender).PopulateMethod();
}
}


i hope i forget ntohing,
and hope that's help

ROM
 
Romain:

Thank you very much for your response. Not knowing much
of the .NET IDE, would your proposed solution work
directly with the actual .NET IDE events? I am not
looking to trap a change event in my particular program,
I am looking to hook into change event that happens in
the Properties Window of the .NET development environment
itself. So, while I am creating a form, for example, and
add a text box, I can set properties such
as "BindingSource" for it in the Properties window. I am
looking to hook into THIS event, if there is one
exposed. Kind of like I can hook into debug events,
project build events, etc. with envDTE.

The reason why I am doing this is that I would like to
automate parts of the property propagation during system
development.

Pertti
 
Sorry pertti

I did not understood what you was needing .... I do'nt know how to achieve
that
sorry

ROM


<[email protected]> a écrit dans le message de [email protected]...
Romain:

Thank you very much for your response. Not knowing much
of the .NET IDE, would your proposed solution work
directly with the actual .NET IDE events? I am not
looking to trap a change event in my particular program,
I am looking to hook into change event that happens in
the Properties Window of the .NET development environment
itself. So, while I am creating a form, for example, and
add a text box, I can set properties such
as "BindingSource" for it in the Properties window. I am
looking to hook into THIS event, if there is one
exposed. Kind of like I can hook into debug events,
project build events, etc. with envDTE.

The reason why I am doing this is that I would like to
automate parts of the property propagation during system
development.

Pertti
 
Back
Top