Phill,
In addition to deriving a new class from Control.ControlCollection and
overriding some of its methods. To get Control to use your new class you
need to override Control.CreateControlsInstance to create a new instance of
your ControlCollection.
However!! I would do as Herfried suggested & handle the Control.ControlAdded
& Control.ControlRemoved events.
Note the above are advanced members VB.NET normally hides them in both the
Object Browser & the code editor. Use "Show hidden members" in the object
browser to see them, use "Tools - Options - Text Editor - Basic - General -
Hide advanced members" to see them in the code editor.
Hope this helps
Jay
"Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> wrote in message
news:c7**********@yarrow.open.ac.uk...
Is it possible to extend the Windows.Forms.Form.ControlCollection
class and override it's Add method?
I'm adding controls to a Form and want to [automatically] hook up
Event Handling for the Form to deal with on behalf of each Control.
I /thought/ the best way to do this would be to inherit from and
override the Add method on the Form.ControlCollection class and
put some AddHandler statements in there. This much I can do but the
bit I'm missing is how to get the Form to use /my/ ControlCollection
rather than the standard one.
Any suggestions?
TIA,
Phill W.