[HowTo] Find the Component Container

        [Browsable(true)]
        [Category("Data"), Description("The parent container, usually the form, that contains the controls on which the ErrorProvider can display error icons "), Localizable(true)]
        public ContainerControl ContainerControl
        {
            get { return _containerControl; }
            set { _containerControl = value; }
        }
        public override ISite Site
        {
            get { return base.Site; }
            set
            {
                base.Site = value;
                if (value == null)
                {
                    return;
                }

                IDesignerHost host = value.GetService(typeof(IDesignerHost)) as IDesignerHost;
                IComponent componentHost = host.RootComponent;
                if (componentHost is ContainerControl)
                {
                    ContainerControl = componentHost as ContainerControl;
                }
            }
        }

Source : @WiredPrairie


Leave a Reply