예제 #1
0
        public void AddChildControl(Control ctl)
        {
            if (ChildControls.Contains(ctl))
            {
                return;
            }

            ChildControlListAddingEventArgs arg = new ChildControlListAddingEventArgs(ctl);

            AddingChildControl?.Invoke(this, arg);
            if (!arg.IsCancel)
            {
                try { ctl.ControlAdded += ChildControlList_ControlAdded; } catch { }
                try { ctl.ControlRemoved += ChildControlList_ControlRemoved; } catch { }

                List <Control> controls = GetChildControls(ctl);
                controls.Add(ctl);
                ChildControls.AddRange(controls);
            }
        }
예제 #2
0
        private void UIComponent_FindedControl(object sender, FindedControlEventArgs e)
        {
            if (ChildControls.Contains(e.Control))
            {
                return;
            }

            if (!e.IsCancel)
            {
                ChildControlListAddingEventArgs arg = new ChildControlListAddingEventArgs(e.Control);
                AddingChildControl?.Invoke(this, arg);
                if (!arg.IsCancel)
                {
                    string n = e.Control.Name;
                    // AddChildControl(e.Control);
                    ChildControls.Add(e.Control);
                    try { e.Control.ControlAdded += ChildControlList_ControlAdded; } catch { }
                    try { e.Control.ControlRemoved += ChildControlList_ControlRemoved; } catch { }
                }
            }
        }