0

I'm using a DateTimePicker in a form and then showing the date and time I pick in an textbox. My problem is that when I select a date the first time, it shows me something like:

11/05/2011 09:17:29 p.m.

Then I pick another date and it shows me this:

19/05/2011 09:17:29 p.m.

Only the date is updated, why I can't update the time or how can I do it?

I'm doing the update with this line of code:

fecha.Text = dateTimePicker1.Value.ToString();
6
  • 2
    Is this in WinForms, ASP, or WPF? Commented May 20, 2011 at 3:22
  • Can you provide code about how you are updating the textbox Commented May 20, 2011 at 3:25
  • fecha.Text = dateTimePicker1.Value.ToString(); Commented May 20, 2011 at 3:26
  • @PachinSV are you initiating it like dateTimePicker.Value = DateTime.Now? Also when you select the date do you expect it to update the time to current time or to 00:00 Hrs? Commented May 20, 2011 at 3:36
  • I'm not initiating the date picker with any value... and yes I was expecting update the time when I select another date. Commented May 20, 2011 at 3:42

1 Answer 1

2

You'll need to set myDateTimePicker.ShowUpDown = true for it to show\update the time. In that case also, one has to change the time in ui to be reflected into your code.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.