如何不断检查是否已选中复选框,如果是,请执行某些操作。
如果未勾选则撤消更改。
public Form1()
{
InitializeComponent();
statusCmb.Text = "All";
while (advancedQueryCb.Checked == true)
{
statusCmb.Text = null;
String SQL = "SELECT * FROM bd;
}
}
答案 0 :(得分:3)
您可以订阅Checked
属性值更改时将会引发的复选框的CheckedChangedEvent
:
public Form1()
{
InitializeComponent();
statusCmb.Text = "All";
advancedQueryCb.CheckedChangedEvent += (sender, e) =>
{
var checkbox = (CheckBox)sender;
if (checkbox.Checked)
{
// The checkbox has been checked, so you can perform the
// necessary logic here
}
};
}
答案 1 :(得分:2)
那是什么事件
public Form1()
{
InitializeComponent();
advancedQueryCb.CheckedChanged += advancedQueryCb_CheckedChanged;
}
void advancedQueryCb_CheckedChanged(object sender, EventArgs e)
{
tatusCmb.Text = null;
String SQL = "SELECT * FROM bd;
}