How to restrict DateTimePicker
to select the time only? I don't know how to disable calendar control which drops when you press the button at the right of DateTimePicker
.
As another suggestion: Use a textbox (or a label) and make it read only. Display the value you want in it. If you have to have a datetimepicker, create both a datetimepicker and a textbox.
We can create a DateTimePicker control using the Forms designer at design-time or using the DateTimePicker class in code at run-time (also known as dynamically). To create a DateTimePicker control at design-time, you simply drag and drop a DateTimePicker control from Toolbox to a Form in Visual Studio.
Set datetimepicker FORMAT property to custom. set CUSTOM FORMAT property to empty string " ". set its TAG to 0 by default.
A snippet out of the MSDN:
'The following code sample shows how to create a DateTimePicker that enables users to choose a time only.'
timePicker = new DateTimePicker(); timePicker.Format = DateTimePickerFormat.Time; timePicker.ShowUpDown = true;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With