//recursive function that Walks through the current form and finds all Mettle custom controls //then add them to our event handeler //this allows us to automatically update them all when a tag is recieved private void AddControl(Control ctl) { //determine if the control is one of our custom ones, //our custom controls all implement ITagInterface if (ctl is MettleLib.ITagInterface) { Trace.WriteLine("found, " + ctl.GetType().ToString()); TagEvents += new TagHandeler(((MettleLib.ITagInterface)ctl).UpdateEvent); ((MettleLib.ITagInterface)ctl).Initialize(); } if (ctl is MettleLib.ITagErrorInterface) { TagErrorEvent += new ErrorHandeler(((MettleLib.ITagErrorInterface)ctl).UpdateEvent); ((MettleLib.ITagErrorInterface)ctl).Initialize(); } //recursive call into children foreach (Control child in ctl.Controls) { AddControl(child); } }