This is the main reason I stopped using components for anything that
needs a reference to the form, because I also could not find any easy
way to do this.
I can think of two techniques to find the form, neither is very
1. Have a public shared property in my application object that gets
set to a reference to the form in my form base class constructor
(before InitializeComponent() is called). When the component
initializes, that property contains a reference to the form being
constructed. This presumes that the component is only created by
dropping it on a form, and never with an explicit New.
2. Add the IDispose interface to the component, as well as a custom
interace. IDispose makes the IDE add a reference to the component in
the form's private 'components' list. After the call to
InitializeComponent(), run through the 'components' list, and for each
item that can be cast to the custom interface, call that interface
passing a reference to the form. The big downside to this method is
that this code has to be put in each derived class, because the
'components' list is private to each derived class.
On Sat, 1 Dec 2007 08:21:03 -0800, Spicy Mikey < XXXX@XXXXX.COM >