Getting separate values for hours and minutes from a DateTimePicke

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
I am using a DateTimePicker set to retrieve time information only. I would
like to separately set the hour increment to 1 and the minutes increment to
30 but I cannot find out how I can use the different sections in the control.
Does anybody has an idea?

Thank you for your attention.

Regards,
 
Hello,
I am using a DateTimePicker set to retrieve time information only. I would
like to separately set the hour increment to 1 and the minutes increment to
30 but I cannot find out how I can use the different sections in the control.
Does anybody has an idea?

Thank you for your attention.

Regards,

Well you can use the DateTime methods for this as follows

DateTime t = now;
DateTime tplus1hr30sec = t.AddHours(1);
tplus1hr30sec = t.AddMinutes(30);

and there you go, you have a time set 1:30 min apart time "t".

Hope this answers your question :)
 
Hello Ahmed,
Thanks for your answer, it is going to help me for sure.

However what I was looking for is the control's possibility but it looks
like we cannot access to the different sections of the time control.

I already did this job years ago in C++ by grouping textbox and spin control
into a dialog but I expected that the C# control encapsulated this for us.

Once again, thanks a lot.
Pierre
 
Me.DateTimePicker1.Value.ToShortTimeString()

Dim T As DateTime

T = New DateTime(0, 0, 0, Me.DateTimePicker1.Value.Hour,
Me.DateTimePicker1.Value.Minute, Me.DateTimePicker1.Value.Second)
 
Back
Top