user1532468
user1532468

Reputation: 1753

Display date and time in datetimepicker

Just a general question because after some research, I cannot seem to find an answer.

Is it possible to display both the date & time in a datetimepicker ?

I have a situation where the time must be selected independently from the date.

I know that a datetimepicker can display just the time or just the date , but I need to display together .

Hope there is an answer to this. Thanks

Upvotes: 1

Views: 15588

Answers (3)

Ajay
Ajay

Reputation: 6590

Try this :

 Private Sub DateTimePickerValueChanged(ByVal obj As Object, _

                                       ByVal ergs As EventArgs)

MessageBox.Show("Datetime :" + DTP.Value.ToString())

For more details see this post : http://www.dotnetheaven.com/article/datetimepicker-control-in-vb.net

Upvotes: 1

Al-3sli
Al-3sli

Reputation: 2181

Try Using CustomFormat for DateTime:

 DateTimePicker1.CustomFormat = "your Format"

Upvotes: 1

Vignesh Kumar A
Vignesh Kumar A

Reputation: 28403

Yes,Using DateTimePicker we can display both date and time together

Try like this

 DateTimePicker1.Format = DateTimePickerFormat.Custom
 DateTimePicker1.CustomFormat = "MM dd yyyy hh mm ss"
 MsgBox(DateTimePicker1.Value)

Or Else you need to set these Property in your DateTimePicker1 as

 Format = Custom
 CustomFormat = "MM dd yyyy hh mm ss"

Upvotes: 8

Related Questions