您的位置:首页 > 其它

Windows窗体设计 添加其他窗口

2013-07-21 11:28 253 查看
1、主窗口

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Windows窗体应用程序1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
anotherForm = new Form2();
}
private Form2 anotherForm;
private void button1_Click(object sender, EventArgs e)
{
anotherForm.Show();
}
}
}


2、从窗口

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Windows窗体应用程序1
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
bShowHide = true;
}
private bool bShowHide;
public bool BShowHide
{
get
{
return bShowHide;
}
set
{
bShowHide = value;
}
}
private void button1_Click(object sender, EventArgs e)
{
if (bShowHide)
{
this.Hide(); bShowHide = !bShowHide;
}
else
{
this.Show(); bShowHide = !bShowHide;
}
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐