首页新闻找找看学习计划

关于winform tabcontrol切换闪烁的问题

0
悬赏园豆:10 [待解决问题]

代码如下:
private void tabFormControl1_SelectedTabChanged(object sender, EventArgs e)
{
this.IsMdiContainer = true;
if (tabFormControl1.SelectedTab == tabFormItem2)
{
tabFormPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
tabFormPanel2.Location = new System.Drawing.Point(0, -5);
Customer cus = new Customer(u);
//设置为非顶级控件
cus.TopLevel = false;
cus.MdiParent = this;
cus.Visible = true;
cus.Dock = DockStyle.Fill;
cus.Show();

            tabFormPanel2.Controls.Add(cus);
            tabFormPanel2.Show();
            this.tabFormControl1.Controls.Add(tabFormPanel2);
            this.tabFormControl1.SelectedTab = tabFormItem2;
        }
        if (tabFormControl1.SelectedTab == tabFormItem3)
        {
            tabFormPanel3.Dock = System.Windows.Forms.DockStyle.Fill;
            tabFormPanel3.Location = new System.Drawing.Point(0, -5);
            SaleUser sale = new SaleUser(u);
            //设置为非顶级控件
            sale.TopLevel = false;
            sale.MdiParent = this;
            sale.Visible = true;
            sale.Dock = DockStyle.Fill;
            sale.Show();
            tabFormPanel3.Controls.Add(sale);
            tabFormPanel3.Show();
            this.tabFormControl1.Controls.Add(tabFormPanel3);
            this.tabFormControl1.SelectedTab = tabFormItem3;
        }
        if (tabFormControl1.SelectedTab == tabFormItem4)
        {
            tabFormPanel4.Dock = System.Windows.Forms.DockStyle.Fill;
            tabFormPanel4.Location = new System.Drawing.Point(0, 0 - 5);
            Allocation alo = new Allocation(u);
            //设置为非顶级控件
            alo.TopLevel = false;
            alo.MdiParent = this;
            alo.Visible = true;
            alo.Dock = DockStyle.Fill;
            alo.Show();

            tabFormPanel4.Controls.Add(alo);
            tabFormPanel4.Show();
            this.tabFormControl1.Controls.Add(tabFormPanel4);
            this.tabFormControl1.SelectedTab = tabFormItem4;
        }
        if (tabFormControl1.SelectedTab == tabFormItem5)
        {
            tabFormPanel5.Dock = System.Windows.Forms.DockStyle.Fill;
            tabFormPanel5.Location = new System.Drawing.Point(0, -5);
            Tag tag = new Tag(u);
            //设置为非顶级控件
            tag.TopLevel = false;
            tag.MdiParent = this;
            tag.Visible = true;
            tag.Dock = DockStyle.Fill;
            tag.Show();
            tabFormPanel5.Controls.Add(tag);
            tabFormPanel5.Show();
            this.tabFormControl1.Controls.Add(tabFormPanel5);
            this.tabFormControl1.SelectedTab = tabFormItem5;
        }
        if (tabFormControl1.SelectedTab == tabFormItem6)
        {
            tabFormPanel6.Dock = System.Windows.Forms.DockStyle.Fill;
            tabFormPanel6.Location = new System.Drawing.Point(0, -5);
            Password pass = new Password(u);
            //设置为非顶级控件
            pass.TopLevel = false;
            pass.MdiParent = this;
            pass.Visible = true;
            pass.Dock = DockStyle.Fill;
            pass.Show();
            tabFormPanel6.Controls.Add(pass);
            tabFormPanel6.Show();
            this.tabFormControl1.Controls.Add(tabFormPanel6);
            this.tabFormControl1.SelectedTab = tabFormItem6;
        }
    }

怎么样可以解决闪烁问题?

恶之必要的主页 恶之必要 | 初学一级 | 园豆:165
提问于:2019-02-15 09:57
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册