This browser is no longer supported. Download Microsoft Edge More info. Contents Exit focus mode. Date Time Picker. Format Property Reference Is this page helpful? Please rate your experience Yes No. Any additional feedback?
Find centralized, trusted content and collaborate around the technologies you use most. Connect and share knowledge within a single location that is structured and easy to search.
I would like to be able to display a DateTimePicker that has a default value of nothing, i. For example, I have a start date dtTaskStart and an end date dtTaskEnd for a task, but the end date is not known, and not populated initially.
Setting the value to null , or an empty string at runtime causes an error, so how can I accomplish this? I have considered using a checkbox to control the enabling of this field, but there is still the issue of displaying an initial value.. NET , but the solution I found for my problem is not a solution for that question, so I think it should remain here for others to find.. Obfuscating the value by using the CustomFormat property, using checkbox cbEnableEndDate as the flag to indicate whether other code should ignore the value:.
In case anybody has an issue with setting datetimepicker control to blank during the form load event, and then show the current date as needed, here is an example:. This allows you to display and use an empty date value, but still allow the user to be able to change the date to something when they wish. The basic concept is the same told by others.
But its easier to implement this way when you have multiple dateTimePicker. When unchecked. When checked. Listen , Make Following changes in your code if you want to show empty datetimepicker and get null when no date is selected by user, else save date.
Now if you want its value be changed back to empty by user interaction, then add checkbox and show text "Clear" with this checkbox. Thats it.. Make visible property true or false as per requirement. How are we doing? Please help us improve Stack Overflow. Take our short survey.
Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. How can I make a DateTimePicker display an empty string? Ask Question. Contents Exit focus mode. Date Time Picker. Custom Format Property Reference Is this page helpful?
Please rate your experience Yes No. Any additional feedback? Namespace: System. Forms Assembly: System.
0コメント