首先需要引入System.Windows.Forms这个程序集
1:创建普通的窗体:
Form Form1 = new Form1();
Form1.Show();
2:创建Model窗体:
Form Form1 = new Form1();
DialogResult FormResult = Form1.ShowDialog();
if ( FormResult == DialogResult.OK )
{
MessageBox.Show("OK");
}
else
if ( FormResult == DialogResult.Cancel )
{
MessageBox.Show("Canel");
}
/*
public enum System.Windows.Forms.DialogResult
{
Abort = 0x00000003,
Cancel = 0x00000002,
Ignore = 0x00000005,
No = 0x00000007,
None = 0x00000000,
OK = 0x00000001,
Retry = 0x00000004,
Yes = 0x00000006,
}
*/
3:创建MDI子窗体
private void button1_Click(object sender, System.EventArgs e)
{
this.IsMdiContainer = true;
Form Form1 = new Form();
Form1.MdiParent = this;
}
OK?