在主表单面板中加载另一个表单

时间:2019-02-28 02:04:48

标签: c# .net winforms user-interface

我想在主表单面板中加载另一个表单。一旦选择了另一种表单,则需要删除主表单,并将新表单设置为面板。

主表单

enter image description here

第二表格

enter image description here

代码

const util = require('util');
const exec = util.promisify(require('child_process').exec);

async function fileLineCount({ fileLocation }) {
  const { stdout } = await exec(`cat ${fileLocation} | wc -l`);
  return parseInt(stdout);
};

// Usage

async someFunction() {
  const lineCount = await fileLineCount({ fileLocation: 'some/file.json' });
}

1 个答案:

答案 0 :(得分:0)

如果要在面板中显示表单,请执行以下操作

private void button1_Click(object sender, EventArgs e)
    {
        Form2 newofrm = new Form2();//new instance
        newofrm.TopLevel = false;//allow to added to panel
        this.panel1.Controls.Add(newofrm);// add to panel
        newofrm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;// remove boarder
        newofrm.Dock = DockStyle.Fill;// completely fill panel
        newofrm.Show();// show the form
    }