日期时间选择器验证 [英] Date time picker validations

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

问题描述

很抱歉发布这个问题,因为它可能对所有人都很愚蠢,但是我没有得到确切的解决方案。

I am sorry for posting this question as it may be find silly to all, but I am not getting the exact solution.

问题是:我的项目中有一个日期时间选择器,它出现在表单中的3个文本框之后,如果在文本框中没有输入任何文本,并且输入提交后,它会给出一条消息(确认),表明要输入的数据。同样,如果未选择日期,则应继续进行。

The question is: I have a Date time picker in my project, it comes after the 3 textboxes in the form, if there is no text is entered in the textbox and enter on submit, it gives a message(validation) that data to be entered. In the same way, if the date is not selected, it should proceed further.

执行此操作的代码是什么,可用于其他文本框但不适用于datetimepicker控件的代码是:

What is the code to do that, the code which worked for other textboxes and not working for datetimepicker control is:

       if (dateInsert.Value.ToString() = string.Empty)
        {
            MessageBox.Show("Please select date!");
            dateInsert.Focus();
            return;
        }


推荐答案

请更正代码并查看如果有效

Please correct the code and see if it works

               if (dateInsert.Value.ToString() == "")
              {
                MessageBox.Show("Please select date!");
                dateInsert.Focus();
                return;
               }

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

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