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后就能显示了?哪里的问题呢?
每个新窗体都需要加一个:
//tag 窗体
Password pass=new Password();
pass.MdiParent = this;