Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make DateTimePicker work as TimePicker only in WinForms

Tags:

c#

winforms

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.

like image 567
Blablablaster Avatar asked Apr 08 '11 10:04

Blablablaster


People also ask

How do I make DateTimePicker readonly?

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.

How do I use DateTimePicker in Windows form?

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.

How can I make a DateTimePicker display an empty string?

Set datetimepicker FORMAT property to custom. set CUSTOM FORMAT property to empty string " ". set its TAG to 0 by default.


1 Answers

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; 
like image 196
Peter Avatar answered Sep 19 '22 18:09

Peter