首页新闻找找看学习计划

关于Winform窗体 tabFormControl控件 嵌入form窗体问题

0
悬赏园豆:10 [已解决问题] 解决于 2019-01-26 10:12

tabFormControl控件内的tabFormPanel要放入Form窗体,但是每次运行项目,窗体在panel内的位置都会改变,怎么样能把窗体位置固定?我给窗体的Location变量赋了位置类定位,无效果。
以下是我的代码:

private void button4_Click(object sender, EventArgs e)
{
        //新建tab项
        TabFormItem tabFormItem2=new TabFormItem();
        TabFormPanel tabFormPanel2 = new TabFormPanel();
        tabFormItem1.Checked = false;
        tabFormItem2.Checked = true;
        tabFormItem2.CloseButtonVisible = true;
        tabFormItem2.ForeColor = System.Drawing.Color.Black;
        tabFormItem2.Name = "tabFormItem2";
        tabFormItem2.Text = "修改密码";
        tabFormItem2.Panel = tabFormPanel2;
        this.tabFormControl1.Items.AddRange(new DevComponents.DotNetBar.BaseItem[] {tabFormItem2});
        
        //新建panel
        tabFormPanel2.Name = "tabFormPanel2";
        tabFormPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
        tabFormPanel2.Location = new System.Drawing.Point(0, 0);
        tabFormPanel2.Style.BackColor = System.Drawing.Color.WhiteSmoke;
        tabFormPanel2.Style.Class = "TabFormPanel";
        tabFormPanel2.Style.CornerType = DevComponents.DotNetBar.eCornerType.Square;
        tabFormPanel2.StyleMouseDown.CornerType = DevComponents.DotNetBar.eCornerType.Square;
        tabFormPanel2.StyleMouseOver.CornerType = DevComponents.DotNetBar.eCornerType.Square;
        
        //新窗体
        Password pass = new Password(u);
        pass.Location = new Point(0, 0);
        pass.Show();
        //设置为非顶级控件
        pass.TopLevel = false;
        tabFormPanel2.Controls.Add(pass);
        tabFormPanel2.Show();
        this.tabFormControl1.Controls.Add(tabFormPanel2);
    }

效果:

而且每次我点击按钮tabFormPanel里的Form都没有显示,切换一下tabFormItem后就能显示了?哪里的问题呢?

恶之必要的主页 恶之必要 | 初学一级 | 园豆:165
提问于:2019-01-25 15:45
< >
分享
最佳答案
0

每个新窗体都需要加一个:
//tag 窗体
Password pass=new Password();
pass.MdiParent = this;

恶之必要 | 初学一级 |园豆:165 | 2019-01-26 10:11
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册