用于打开新窗口的C#简单代码 [英] C# simple code for open new window

查看:153
本文介绍了用于打开新窗口的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


这篇关于用于打开新窗口的C#简单代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆