I want to do this in code .cs file Can some help write a regex datetime validation. I have two datetime controls, I want to validate that the datetime is a valid date and if not throw and error. I also want to throw an error if the datetime is outside of the range MIN and MAX review below. the format I using as far as datatime goes, 'YYYYMMSS:hhmmss' or can I force the user to stop typing in the datetime control, At the moment I can type in the datetime picker, I only want the user to pick from the datetime picker
MIN date and Max Date
19670101 and 30000101
Jan 01, 1967 and Jan 01, 3000
Maybe one possible approach could be if you handle suitable event and call DropDown() method.
For example:
private void ultraDateTimeEditor1_MouseClick(object sender, MouseEventArgs e) { ultraDateTimeEditor1.DropDown(); } private void ultraDateTimeEditor1_KeyDown(object sender, KeyEventArgs e) { ultraDateTimeEditor1.DropDown(); }
private void ultraDateTimeEditor1_MouseClick(object sender, MouseEventArgs e)
{
ultraDateTimeEditor1.DropDown();
}
private void ultraDateTimeEditor1_KeyDown(object sender, KeyEventArgs e)
Let me know if you have any questions.
How to stop people from typing in the datetime picker control, i just want them strickly use the picker and nothing else.
Hello Keith,
I think that it is very easy to achieve desired behavior without using Regex. Maybe you could set the properties below:
ultraDateTimeEditor1.FormatString = "yyyyMMddHHmmss";ultraDateTimeEditor1.MaskInput = "yyyy/mm/dd hh:mm:ss";Also set mentioed interval ( Min and Max date ) to properties MinDate and MaxDate and handle ultraDateTimeEditor1_Validated() event.
Also you could used property InvalidTextBahavior. There are few option, and you could choose the best option for your scenario. For example : InvalidTextBahavior = RevertToOriginalValue.
Regards