C#中如何检查,看是否有复选框被另一种形式的检查? [英] C# How can I check to see if a checkbox is checked on another form?
本文介绍了C#中如何检查,看是否有复选框被另一种形式的检查?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用C#和我想检查,看看是否在主窗体上的复选框被选中,如果是运行一些代码,但问题是我在一个类文件(文件,没有形式,类文件是否正确?)。什么是做到这一点?
由于
杰米
解决方案最简单的方法DIV>
最好的办法是创建一个布尔暴露的的
属性经过
价值形态上复选框
。
公共BOOL OptionSelected
{
{返回checkBox.Checked; }
集合{checkBox.Checked =价值; } //设置是可选的
}
I'm using C# and I'd like to check to see if a checkbox on the main form is checked and if so run some code, the problem is I'm in a class file (file with no form, is class file correct?). What is the easiest way to do this?
Thanks Jamie
解决方案
The best option is to create a boolean
property on the Form that exposes the Checked
value of the CheckBox
.
public bool OptionSelected
{
get { return checkBox.Checked; }
set { checkBox.Checked = value; } // the set is optional
}
这篇关于C#中如何检查,看是否有复选框被另一种形式的检查?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文