问题描述
很抱歉发布这个问题,因为它可能对所有人都很愚蠢,但是我没有得到确切的解决方案。
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;
}
这篇关于日期时间选择器验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!