使用相同窗口形式的各种功能 [英] Various Functionalities of using same window form

查看:62
本文介绍了使用相同窗口形式的各种功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理Window表单.我有两种获胜形式.在第一种形式中,我有两个按钮添加"和修改".当我单击任意一个按钮时,我应该获得第二个表单,并且通过单击任意一个按钮,我都能够成功获取第二个表单.但是问题是我只想显示与按下的按钮有关的某些功能.

例如:在第二种形式中,我有3个分组框和5个按钮,它们具有各自的功能.现在,当我单击添加"按钮时,我必须仅获得2个分组框和3个按钮,而当我单击修改"按钮时,则必须获得3个分组框和2个按钮.

I am working on Window forms. I have two win forms. In first form I have two buttons Add and Modify. When I click either button I should get the second form and I am able to succeed in geting second form by clicking the either buttons. But the problem is I want to display only some functionalities in that form related to the button pressed.

e.g.: In second form I have 3 groupboxes and 5 buttons which have their own functionalities. Now when I click add button I have to get only 2 groupboxes and 3 buttons and when I click Modify button I have to get 3 groupboxes and 2 buttons.

How to do that?

推荐答案

通过属性或构造函数将某些内容传递给第二种形式,告诉它​​要显示的内容
Pass something to the second form, via a property or the constructor, telling it what to show


在您的form1中以这种方式创建变量
in your form1 create a variable in this way
public static string task="";



在您的addbtn_click()



in your addbtn_click()

task="add";
.....



在您的Modifybtn_click()



in your Modifybtn_click()

task="modify";
.....



在您的form2_Load()



in your form2_Load()

if(Form1.task=="add")
{
groupBox1.Visible=true;
groupBox2.Visible=true;
groupBox3.Visible=true;
button1.Visible=true;
button2.Visible=true;
//or something like that
}
if(Form1.task=="modify")
{
groupBox1.Visible=true;
groupBox2.Visible=false;
groupBox3.Visible=true;
button1.Visible=true;
button2.Visible=false;
//or something like that
}




这可能会对您有所帮助.




This may help you.


这篇关于使用相同窗口形式的各种功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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