使用C#检查VS2019 .NET 4.7.03 Windows应用程序中的复选框的状态? [英] Checking the state of a checkbox in VS2019 .NET 4.7.03 Windows Application using C#?
问题描述
你好!
我有一个Windows窗体应用程序是VS2019,带有一个复选框,我想做一件事,如果它如果没有按下按钮检查,则检查另一个。
I have a windows forms application is VS2019 with a checkbox that i want to do one thing if it is checked and another if it isn't checked at the press of a button.
假设我的代码是这样的:
Let's say my code is this:
private void Button_Click(object sender, RoutedEventArgs e)
{
if (checkbox1 is checked, do this)
{
(Code if checkbox1 is checked)
}
else
{
(Code if checkbox1 isn't checked)
}
}
在VS2017和C#中有编码背景我以前只能使用Checkbox1.Checked = true但是现在好像是".Checked" part是一个事件而不是属性。
Having a background of coding in VS2017 and with C# i used to just be able to use Checkbox1.Checked = true for this but now it seems like the ".Checked" part is an event and not a propertie.
我在Windows 10上使用VisualStudio Community 2019版本16.1.1和.NET Framework 4.7.03190。
I am using VisualStudio Community 2019 version 16.1.1 with .NET Framework 4.7.03190 on windows 10.
推荐答案
我有一个Windows窗体应用程序是VS2019,带有一个复选框,我想做一件事,如果它被检查,另一个,如果它不是'按下按钮检查。
...
$
在VS2017中使用编码的背景和使用C#我以前只能使用Checkbox1.Checked =这是真的,但现在似乎是".Checked" part是一个事件,而不是一个属性。
I have a windows forms application is VS2019 with a checkbox that i want to do one thing if it is checked and another if it isn't checked at the press of a button.
...
Having a background of coding in VS2017 and with C# i used to just be able to use Checkbox1.Checked = true for this but now it seems like the ".Checked" part is an event and not a propertie.
这些事情没有改变,所以你必须在新项目中做一些不同的事情。
Such things haven't changed, so you must be doing something different in your new project.
戴夫
这篇关于使用C#检查VS2019 .NET 4.7.03 Windows应用程序中的复选框的状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!