Add a subroute to multiple forms
I'm trying to find a way to add a subroutine to multiple forms in VB.net 2k5.
I'm instancing some forms as a property of a class and I need an event that triggers to handle their .dispose property.
I think that's the proper way to describe it. I'm a bit of a noob. Just in case that's not understandable, I'll break it down a bit more below.
I have a public class which contains "Public Myform as Object".
There is are a number of inherited classes which contain "Myform = new (appropriate form)".
When the instance of the form is disposed, I'd like to trigger an additional event.
I can go into each form and add the event, but to keep modification simple, I was hoping there was a way I could create a "handles Myform.dispose" from within the main public class, since it will be the same for all of the various forms that will be loaded.
Initially, I tried using "Public Myform as Form" but because the inherited classes have overloaded events which call properties of their specific form this doesn't seem to work.
Any suggestions?
Re: Add a subroute to multiple forms
What I've done is to add a public sub in a module and added a call statement to the .disposed handler of each of the forms in question.
It works well for consolidating the code into one place for updates, but I'm still looking for a way to add this code dynamically to the form from within the class if anyone has any thoughts.