[.net] How can I make a DateTimePicker display an empty string?

When I want to display an empty date value I do this

            if (sStrDate != "")
            {
                dateCreated.Value = DateTime.Parse(sStrDate);
            }
            else
            {
                dateCreated.CustomFormat = " ";
                dateCreated.Format = DateTimePickerFormat.Custom;
            }

Then when the user clicks on the control I have this:

            private void dateControl_MouseDown(object sender, MouseEventArgs e)
            {
                ((DateTimePicker)sender).Format = DateTimePickerFormat.Long;    
            }

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.

Keep in mind that sStrDate has already been validated as a valid date string.

Examples related to .net

You must add a reference to assembly 'netstandard, Version=2.0.0.0 How to use Bootstrap 4 in ASP.NET Core No authenticationScheme was specified, and there was no DefaultChallengeScheme found with default authentification and custom authorization .net Core 2.0 - Package was restored using .NetFramework 4.6.1 instead of target framework .netCore 2.0. The package may not be fully compatible Update .NET web service to use TLS 1.2 EF Core add-migration Build Failed What is the difference between .NET Core and .NET Standard Class Library project types? Visual Studio 2017 - Could not load file or assembly 'System.Runtime, Version=4.1.0.0' or one of its dependencies Nuget connection attempt failed "Unable to load the service index for source" Token based authentication in Web API without any user interface

Examples related to winforms

How to set combobox default value? Get the cell value of a GridView row Getting the first and last day of a month, using a given DateTime object Check if a record exists in the database Delete a row in DataGridView Control in VB.NET How to make picturebox transparent? Set default format of datetimepicker as dd-MM-yyyy Changing datagridview cell color based on condition C# Inserting Data from a form into an access Database How to use ConfigurationManager

Examples related to datetimepicker

Angular-Material DateTime Picker Component? DateTimePicker time picker in 24 hour but displaying in 12hr? Set default format of datetimepicker as dd-MM-yyyy Set default time in bootstrap-datetimepicker Get the value of bootstrap Datetimepicker in JavaScript Bootstrap date and time picker datetimepicker is not a function jquery How to change the date format of a DateTimePicker in vb.net jQuery date/time picker How to get only the date value from a Windows Forms DateTimePicker control?