예제 #1
0
        private DBObjectControl CreateNewForm(DBObject obj)
        {
            DBObjectControl childForm = null;

            //see if already open
            foreach (TabPage p in tabControl1.TabPages)
            {
                if (p.Text.Equals(obj.FullName))
                {
                    childForm = p.Tag as DBObjectControl;
                    tabControl1.SelectedTab = p;
                    break;
                }
            }

            //new?
            if (childForm == null)
            {
                childForm          = new DBObjectControl();
                childForm.DBObject = obj;
                childForm.RefreshDisplay();
                childForm.ActiveObjectChanged += childForm_ActiveObjectChanged;

                //activate the new tab
                this.ActivateForm(childForm);
            }

            return(childForm);
        }
예제 #2
0
        private void ActivateForm(DBObjectControl child_form)
        {
            // If child form is new and no has tabPage,
            // create new tabPage
            if (child_form.Tag == null)
            {
                // Add a tabPage to tabControl with child
                TabPage tp = new TabPage(child_form.DBObject.FullName);

                //tab icon
                if (child_form.DBObject is DBSchema)
                {
                    tp.ImageIndex = 13;
                }
                if (child_form.DBObject is DBTable)
                {
                    tp.ImageIndex = 3;
                }
                if (child_form.DBObject is DBView)
                {
                    tp.ImageIndex = 17;
                }
                if (child_form.DBObject is DBColumn)
                {
                    tp.ImageIndex = 4;
                }

                tp.Tag    = child_form;
                tp.Parent = tabControl1;
                tabControl1.SelectedTab = tp;
                tp.Controls.Add(child_form); //show it
                child_form.Parent = tp;
                child_form.Dock   = DockStyle.Fill;
                child_form.Tag    = tp;
            }
        }