如何在DateTimePicker上提示用户? [英] How to prompt user on a DateTimePicker ?

查看:132
本文介绍了如何在DateTimePicker上提示用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一种检查此类空文本框的已知方法

There''s a known way to check for empty textboxes like these

 Sub Check_Textbox()
        Dim r As DialogResult
        If txtStaffID.Text = ""
Then

            r = MessageBox.Show("Please try again.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)



但是,有没有一种方法可以在DateTimepicker上提示用户?这是我希望系统提示用户的内容和方式:

DateTimePicker检查日期.如果不是提前3天,它将提示用户并禁止执行任何操作.

可以采取上述行动吗?如果是这样,我能知道它的编码吗?在此先谢谢您.



But is there a way to prompt the user on a DateTimepicker? here is what and how i want the system to prompt the user:

The DateTimePicker checks the date. If it''s not 3 days in advance, it will prompt the user and disallow any action.

Is the above action possible? If so, can i know the codings to it? Thanks in advance.

推荐答案

您可以考虑使用DateTimePicker ValueChanged
You can consider using the DateTimePicker ValueChanged event[^].
Handle this event, read the date value (from the event''s parameters) and if the data does not meet the condition, display a message box similar to the way you were doing this for the textbox.


是的,您需要编写代码以检查日期时间选择器中的日期.如果使用DateTime.Now从另一个日期时间中减去一个日期时间,则将获得一个Timepan.如果天差< 3,然后显示您的消息.
Yes, you need to write code that checks the date in your datetime picker. If you subtract one date time from another, using DateTime.Now, you get a Timespan. If the difference in days < 3, then you show your message.


这篇关于如何在DateTimePicker上提示用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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