How to get datetimepicker c# winform checked/unchecked event

前端 未结 4 1552
梦毁少年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:03

    I know this is super old but this could help someone.

    You can capture DataTimePicker.MouseUp event

    private void dateTimePicker1_MouseUp(object sender, MouseEventArgs e)
        {
            if (((DateTimePicker)sender).Checked)
            {
                //Do whatever you need to do when the check box gets clicked
            }
            else
            {
                //Do another stuff...
            }
        }
    

    You will need to do the same with KeyUp event in order to get the Space key press that could also activate the checkbox.

提交回复
热议问题