私は通常のフォームを表示するには、次のコードを使用:ショーフォームの共通機能を作成する方法は?
frmEmployeeManage em = null;
private void ShowEmployee_Click(object sender, EventArgs e)
{
if (em == null || em.IsDisposed)
{
em = new frmEmployeeManage();
em.MdiParent = this;
em.FormBorderStyle = FormBorderStyle.None;
em.WindowState = FormWindowState.Maximized;
em.Show();
}
else
{
em.Activate();
}
}
は今、私は、フォームを表示する機能を書きたいです。次のコードでは、関数にパラメータとしてフォームクラスを渡す方法がわかりません。
class CommonService
{
public static void ShowFrom(Form frmChild, Form frmParent)
{
if (frmChild == null || frmParent.IsDisposed)
{
frmChild = new Form(); // How passing the form class here?
frmChild.MdiParent = frmParent;
frmChild.FormBorderStyle = FormBorderStyle.None;
frmChild.WindowState = FormWindowState.Maximized;
frmChild.Show();
}
else
{
frmParent.Activate();
}
}
}
最後に、私は、次の例のようにショーのフォーム機能を使用します。
public static void ShowFrom<T>(ref T frmChild, Form frmParent) where T : Form, new()
{
if (frmChild == null || frmParent.IsDisposed)
{
frmChild = new T(); // How passing the form class here?
frmChild.MdiParent = frmParent;
frmChild.FormBorderStyle = FormBorderStyle.None;
frmChild.WindowState = FormWindowState.Maximized;
frmChild.Show();
}
else
{
frmParent.Activate();
}
}
そして、このようにそれを呼び出す:私は何が必要だと思う
frmEmployeeManage em = null;
CommonService.ShowForm(frmEmployee, this);
何が問題になりましたか? – Berkay