C#使用表格... [英] c# working with forms...

查看:86
本文介绍了C#使用表格...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#Windows窗体中有一个窗体,并且有一个按钮,当我们单击它时,将打开另一个窗体.问题是当其他表单打开时如何隐藏第一个表单.我不想同时使用这两种形式.因此,当我单击按钮时,打开新表单,但旧表单隐藏或关闭...

thnx

I have one form in c# windows form and there is one button that when we click on it there will be open another form. The problem is how can I hide the first form when other form is open. I dont want to have both forms. So when I click in button open the new form but the old form hide or close...

thnx

推荐答案

h5h5,

我假设您有两种形式-Form1& Form2,在Form1上,您有一个按钮可以显示Form2.

在Form1上的Button的Button_Click事件内,编写以下代码即可完成所需的操作.

Hi h5h5,

I assume you have two forms- Form1 & Form2 and on Form1 you''ve a button to show up Form2.

Inside Button_Click event of the button on Form1, write below codes and you''re done with what you want.

private void button3_Click(object sender, EventArgs e)
        {
            Form2 frm = new Form2();
            this.Hide();
            frm.Show();
        }




快乐编码:)
Sunny_K




Happy Coding :)
Sunny_K


当您关闭第一个表单时,如果您关闭了应用程序,则您需要设置应用程序设置设置关机模式->最后一个表单关闭时.
在单击按钮的地方(您显示下一个表单)时,编写这样的代码
when u close first form than if ur application close than you need to set application setting set shutdown mode ->when last form close.
on click of button where u show next form write code like this
NextForm.Show()
            Close()


这篇关于C#使用表格...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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