本文介绍了错误:maskedtextbox为Persian dateTime的TypeValidationCompleted的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
我使用maskedtextbox为用户提供波斯日期时间。我对maskedtextbox的设置是:mask = 0000/00/00 righttoleft = true



我在maskedtextbox上的TypeValidationCompleted代码是:



hii use maskedtextbox for give persian datetime from user. my setting for my maskedtextbox is : mask= 0000/00/00 righttoleft=true

and my code for TypeValidationCompleted on maskedtextbox is :

 private readonly Type dateTimeType = typeof(DateTime);
txtDateS.ValidatingType = dateTimeType;
------------------
private void maskedTextBox1_TypeValidationCompleted(object sender, TypeValidationEventArgs e)
        {
            MaskedTextBox mtb = (MaskedTextBox)sender;


            if (!e.IsValidInput)
            {

                toolTip1.IsBalloon = true;
                toolTip1.Show("date is not true", mtb, -100, -30, 5000);
                mtb.Clear();
            }
            else
            {
                DateTime dt;
                if (!DateTime.TryParse(e.ReturnValue.ToString(), out dt))
                {
                    toolTip1.IsBalloon = true;
                    toolTip1.Show("date is not true ", mtb, -100, -30, 5000);
                    e.Cancel = true;
                    mtb.Clear();
                }
            }
        }





现在当我在maskedtextbox 1394/02/28中输入时是非常好,工作。但当我输入maskedtextbox 1394/02/29或1394/02/30或1394/02/31它不起作用并给我datetime时无效为什么?为什么不工作29,30,31?



如何解决这个问题?



now when i Typing in maskedtextbox 1394/02/28 is very good and work. but when i typing in maskedtextbox 1394/02/29 or 1394/02/30 or 1394/02/31 It does not work and give me datetime is not valid why ? why not work for 29 , 30 , 31 ?

how can i solve this problem?

推荐答案


这篇关于错误:maskedtextbox为Persian dateTime的TypeValidationCompleted的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 07:03