本文介绍了我怎样才能浏览形式之间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在C#和窗口形式的newbiest我在做一个项目,我遇到一些问题。
- 如何浏览窗口中的形式(我有一个菜单条,当点击它会显示一个项品牌,所以当我点击它,它应该打开的窗口中,我也用不想要的东西在的MdiParent /容器,我有Form1和Form2,然后我把在Form1的菜单条,这里面有一些Form1的事情,如果使用的MdiParent /集装箱,在Form1内容/东西会阻止窗口2)
2,我用下面的code和问题是我要关闭我的菜单条点击品牌在Form1 ......但如何???
公共部分类Form1中:形态
{
//我把菜单条在Form1设计
公共Form1中()
{
的InitializeComponent();
}
私人无效Form1_Load的(对象发件人,EventArgs的)
{
}
私人无效Check_Click(对象发件人,EventArgs的)
{
窗体2 =检查新的窗体2();
Check.Show();
}
}
解决方案
您不能只是关闭 Form1中
,因为它的主要形式,但可以将其隐藏。使用 this.Hide()
。
私人无效Check_Click(对象发件人,EventArgs的)
{
窗体2 =检查新的窗体2();
Check.Show();
隐藏();
}
不知道这是什么要求。但是......
有很多方法可以实现形式之间的导航,例如:
在 Form1中
:
私人无效的button1_Click(对象发件人,EventArgs的)
{
窗体2窗口2 =新的窗体2();
form2.Tag =这一点;
form2.Show(本);
隐藏();
}
在窗体2
:
私人无效的button1_Click(对象发件人,EventArgs的)
{
VAR Form1中=(Form1中)标签;
form1.Show();
关闭();
}
I am a newbiest in c# and window formi am doing a project and i meet some problem
- how can i navigate forms within the window( i have a menu strip, when click it will show a item "Brand", so when i click it, it should open up within the window , i don't want something using the mdiparent/container, i have form1 and form2, then i put the menu strip in form1, which there is some thing inside form1, if use the mdiparent/container, the form1 content/thing will block the form2 )
2.i use the below code and the problem is i want to close the form1 which i click on " Brand" in the menu strip...but how???
public partial class Form1 : Form
{
// i put the menu strip in form1 design
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void Check_Click(object sender, EventArgs e)
{
Form2 Check = new Form2();
Check.Show();
}
}
解决方案
You cannot just close the Form1
as it is the main form, but you can hide it. Use this.Hide()
.
private void Check_Click(object sender, EventArgs e)
{
Form2 Check= new Form2();
Check.Show();
Hide();
}
[EDIT]
Not sure if this is what is asked. But...
There are many ways to implement navigation between forms, for example:
In Form1
:
private void button1_Click(object sender, EventArgs e)
{
Form2 form2 = new Form2();
form2.Tag = this;
form2.Show(this);
Hide();
}
In Form2
:
private void button1_Click(object sender, EventArgs e)
{
var form1 = (Form1)Tag;
form1.Show();
Close();
}
这篇关于我怎样才能浏览形式之间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!