如何将复选框表单值传递给另一个表单 [英] How can I pass check box form value to another form

查看:154
本文介绍了如何将复选框表单值传递给另一个表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目包含4个复选框和2个按钮,它们将打开两个带有相同复选框值的新表单,这些表单位于我的第一个表单上(如果选中,它们将在两个表单上显示为选中,如果未选中,它们将显示为正常)如果我们选择3个复选框并单击第二个按钮,则打开一个新表单,标签应显示200.如果我选择另一个文本框,标签应更新为300并增加++,如果我取消选中复选框,则值应为减少!!你的任何帮助都是值得的!谢谢

My project contains 4 check boxes and 2 buttons which will open two new form with same check box values which were on my first form(if selected, they will appear as selected on two forms, if not selected they will appear as normal) in which if we select 3 check boxes and click 2nd button it open a new form and a label should display 200. If i select another text box the label should update to 300 and increment ++ and if i unchecked checkbox, the value should be decrease!! any help from you can be appreciable! thank you

推荐答案

您是否尝试过将参数添加到表单的构造函数中?

这可以通过多种方式完成下面的代码只是一个例子:

Have you tried to add a parameter to the constructor of your forms?
This can be done in many ways and the code below is just one example:
public class Form2 : Form
{
    public Form2(params bool checkBoxValues)
    {
        InitializeComponent();
        
        if (checkBoxValues.Length > 0)
            checkBox1.Checked = checkBoxValues[0];
        if (checkBoxValues.Length > 1)
            checkBox2.Checked = checkBoxValues[1];
        if (checkBoxValues.Length > 2)
            checkBox3.Checked = checkBoxValues[2];
    }
}

Form2 frm = new Form2(checkBox1.Checked, checkBox2.Checked, checkBox3.Checked);
frm.ShowDialog();


这篇关于如何将复选框表单值传递给另一个表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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