本文介绍了如何在C#窗体中更改状态之前停止复选框事件触发?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



检查复选框有时会工作,有些时间不合适?

我发现即使我检查了复选框仍然它的属性是假的。我该如何解决这个问题?



我的尝试:



Hi,
when checking check boxes some times it working and some time not appropriately?
I found that even i checked the checkbox still it's property is false . How can i fix this?

What I have tried:

private void checkPOD_CheckedChanged(object sender, EventArgs e)
       {
           if (checkMobAd.Checked)
           {
               txtPOD1.ReadOnly = false;
           }
           else
           {
               txtPOD1.Clear();
               txtPOD1.ReadOnly = true;
           }
       }

推荐答案


private void checkPOD_CheckedChanged(object sender, EventArgs e)
    {
    CheckBox cb = sender as CheckBox;
    if (cb != null)
        {
        if (cb.Checked)
            {
            txtPOD1.ReadOnly = false;
            }
        else
            {
            txtPOD1.Clear();
            txtPOD1.ReadOnly = true;
            }
        }
    }


这篇关于如何在C#窗体中更改状态之前停止复选框事件触发?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 18:20