Select the input mask 'short date and time' and validating type will be DateTime by default.
Call ValidateText method to get the parsed instance of the validating type, or use the e.ReturnValue from TypeValidationCompleted event.
You can learn more about the MaskedTextBox class from here: MaskedTextBox Class (System.Windows.Forms)
Johns' answer is absolutely correct but as an alternative that I think it's simpler:
you can also replace this masked text box for a DateTimePicker, and set 'ShowUpDown = True'; 'Format = Custom'; 'CustomFormat = dd/MM/yyyy hh:mm' that you automatically have a datetime type and don't have to validate and will give an effect very similar to the masked box.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.