在Windows应用程序中单击复选框动态显示表单 [英] Display Form Dynamically on click on checkbox in windows application

查看:94
本文介绍了在Windows应用程序中单击复选框动态显示表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了4个表单来输入员工详细信息.第一种形式是用户模块选择屏幕.我在其中添加了3个复选框.如果用户只想查看前两个表单,则可以选中前两个复选框.这样用户只能查看前两个表单而不是最后一个,反之亦然.只能查看此表单的其余表单是隐藏的.我希望根据用户的选择复选框显示表单,而未选择的复选框隐藏表单.

I have created 4 forms for enter employee details. first form is user module selection screen. In that i have added 3 checkbox.If user want to view only first 2 form he can checked first two checkbox.So that user can view only first two form not last one and vice versa.according to user select form by clicked on checkbox he can view only this form rest of the form is hidden.i want form to be dispaly according to user select checkbox and hidden form for not selected checkbox.

推荐答案

在这里可以使用复选框的 CheckedChanged 事件显示和隐藏表单
在该事件过程中,实现您的逻辑.


here you can use CheckedChanged event of checkbox for showing and hiding forms
In that event procedure, implement your logic.


// set Tag properties of each textbox to object of eact form
// e.g 
CheckBox1.Tag = new Form1();CheckBox2.Tag = new Form2();CheckBox3.Tag = new Form3();
//Bind this event procedure to all checkboxes. In CheckedChanged Event write following
CheckboxSelectionChanged(Object sender, EventArgs e)
{
 string FormName=((CheckBox)sender).GetType().Name;
if((CheckBox)sender).Checked)
{

 if(FormName=="Form1")
   (((CheckBox(sender)).Tag) as Form1).Show();
 else if(FormName=="Form2")
    (((CheckBox(sender)).Tag) as Form2).Show();
 . 
 .
 .
}
else
{
  if(FormName=="Form1")
   (((CheckBox(sender)).Tag) as Form1).Close();
 else if(FormName=="Form2")
    (((CheckBox(sender)).Tag) as Form2).Close();
 .
 .
 .
}
}


这篇关于在Windows应用程序中单击复选框动态显示表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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