How to get datetimepicker c# winform checked/unchecked event

前端 未结 4 1567
梦毁少年i
梦毁少年i 2021-02-19 04:15

There is a check box in the datetimepicker control of winforms .net. But I could not find the event that is triggered when the check box is checked or unchecked . Is there a way

4条回答
  •  长发绾君心
    2021-02-19 05:05

    You´ll have to store the old "checked" value in order to compare to the new one, so you´ll be able to determine if the "checked" state has changed:

    bool oldDateChecked = false; //if it's created as not checked
    
    private void dtp_filtro_date_ValueChanged(object sender, EventArgs e)
    {
        if (this.dtp_filtro_date.Checked != oldDateChecked)
        {
            oldDateChecked = this.dtp_filtro_date.Checked;
            //do your stuff ...
    
        }
    }
    

提交回复
热议问题