在c#中关闭旧表单 [英] Closing old form in c#

查看:56
本文介绍了在c#中关闭旧表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要帮助我在c#编码并且我使用对象引用了两个表单但是无论何时我读取主表单打开两次的代码。我有一个主表格和第二表格。第二个表单有两个复选框,checkbox1和cbeckbox2。 checkbox1是在单击时禁用主窗体中的按钮但是随时单击checkbox1它会打开主窗体两次

这是用于引用这两种形式的代码:

Form1 op = new Form1();

op.Show();

解决方案

你试过ShowDialog吗?



 Form1 op =  new  Form1(); 
op.ShowDialog( this );


i need help am coding in c# and i have reference two forms using object but anytime i read the code the main form opens twice. I have a main form and a second form. the second form has two checkboxes,checkbox1 and cbeckbox2. checkbox1 is to disable a button in the main form when click but anytime checkbox1 is clicked it opens the main form twice
This is the code use to reference the two forms:
Form1 op = new Form1();
op.Show();

解决方案

Have you tried with ShowDialog?

Form1 op = new Form1();
op.ShowDialog(this); 


这篇关于在c#中关闭旧表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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