复选框的if语句 [英] If statements for Checkboxes

查看:93
本文介绍了复选框的if语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何编写语句来查看一个或另一个复选框是否被选中。

I wanted to know how to write if statements to see if one or another check box is checked or not.

我有两个复选框。我希望它检查是否选中了复选框1,复选框2为空,然后调用此函数,如果复选框2被选中,复选框1为空,则调用了另一个函数。

I have two check boxes. I wanted it to check to see if checkbox 1 is checked and checkbox 2 is null then call this function, and if checkbox 2 is checked and checkbox 1 is null then call another function.

使用IF语句非常糟糕,不确定如何将复选框转换为可读值。

Pretty bad with IF statements and not sure how to convert the checkbox into a readable value.

推荐答案

我假设您的意思是未选中。我没有C#编译器,但是:

I'm making an assumption that you mean not checked. I don't have a C# compiler handy but:

if (checkbox1.Checked && !checkbox2.Checked)
{

}
else if (!checkbox1.Checked && checkbox2.Checked)
{

}

这篇关于复选框的if语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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