用于打开新窗口的C#简单代码
问题描述:
我正在使用c#express 2008。我的问题是当我点击按钮时如何打开一个具有指定高度和宽度的新窗口?
i am using c# express 2008 . my question is how to open a new window with specified height and width when i click on a button?
答
假设您正在使用Windows窗体,您可以例如,创建一个新表单,然后显示它,例如
Assuming you are working with Windows Forms, you may, for instance, create a new form and then show it, e.g.
private void btnShowChild_Click(object sender, EventArgs e)
{
ChildForm cf = new ChildForm();
cf.Width = 400;
cf.Height = 400;
cf.ShowDialog(this);
}
以下是通过指定位置和大小打开窗口的代码
表格f1 =新表格();
f1.SetBounds(0,0,200,500);
f1.Show();
以下是通过指定尺寸打开窗口的代码
表格f2 =新表格();
f2.Height = 100;
f2.Width = 100;
f2.Show( );
希望这是你要求的
Following is the code to open window by specifying location and size
Form f1 = new Form();
f1.SetBounds(0, 0, 200, 500);
f1.Show();
Following is the code to open window by specifying size
Form f2 = new Form();
f2.Height = 100;
f2.Width = 100;
f2.Show();
Hope this is what you are asking for