初接触Windows Form,不用MDI,能否实现Web Form中IFRAME的功能
如题:
MainForm中的容器控件能否根据需要加载一个子窗体。
------最佳解决方案--------------------设置toplevel = false就可以了
SubForm sb = new Subform();
sb.toplevel = false;
sb.dockstyle = dockstyle.fill;
panel1.Controls.add(sb);
sb.show();
------其他解决方案--------------------
Form2 f2 = new Form2();
f2.TopLevel = false;
f2.FormBorderStyle = FormBorderStyle.None;
this.panel1.Controls.Add(f2);
f2.Show();
用Panel天价就可以了。
------其他解决方案--------------------
就是这个思路
private void FrmTableLayout_Load(object sender, EventArgs e)
{
var frmTimeM1A = new FrmTime("M1A");
frmTimeM1A.TopLevel = false;
frmTimeM1A.FormBorderStyle = FormBorderStyle.None;
frmTimeM1A.StartPosition = FormStartPosition.CenterParent;
frmTimeM1A.Dock = DockStyle.Fill;
this.pnlM1A.Controls.Add(frmTimeM1A);
frmTimeM1A.Show();
var frmTimeM1B = new FrmTime("M1B");
frmTimeM1B.TopLevel = false;
frmTimeM1B.FormBorderStyle = FormBorderStyle.None;
frmTimeM1B.StartPosition = FormStartPosition.CenterParent;
frmTimeM1B.Dock = DockStyle.Fill;
this.pnlM1B.Controls.Add(frmTimeM1B);
frmTimeM1B.Show();
}
效果如图