C#中的日期时间选择器中的连续错误 [英] continuous error in date time picker in c#

查看:62
本文介绍了C#中的日期时间选择器中的连续错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用日期时间选择器,这是一个代码

hi I am using date time picker this is a code

string s = "2011-06-16T05:07:57+0000";


private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
    DateTime theDateA = DateTime.Parse(s);

    if (Convert.ToDateTime(dateTimePicker1.Text)> theDateA)
    {
        MessageBox.Show("ERROR");
    }
}



为什么我在满足条件时发现连续错误,所以应该只显示一次
有什么建议吗?



why i am finding continuous error when it fullfills the condition, it should display once only
any suggestion?

推荐答案

必须有一些东西可以改变DateTimePicker中的选定值.这就是事件再次被触发的原因.检查调用堆栈是否显示任何内容.

为DateTimePicker使用SelectedValue而不是Text属性.
There has to be something which is changing the selected value in the DateTimePicker. That''s why the event gets fired again. Check the call stack if it shows anything.

Use SelectedValue and not Text property for DateTimePicker.


这篇关于C#中的日期时间选择器中的连续错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆