本文介绍了如何获取DateTimePicker C#Winform已选中/未选中事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

winforms .net的datetimepicker控件中有一个复选框。
但是我找不到当复选框处于选中状态或未选中状态时触发的事件。
是否有出路?

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 out?

推荐答案

您必须存储旧的 checked值才能与新的相比,因此您可以确定已检查状态是否已更改:

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 ...

    }
}

这篇关于如何获取DateTimePicker C#Winform已选中/未选中事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 03:11