473,409 Members | 1,970 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,409 software developers and data experts.

DateTimePicker...

How do I display the date AND the time in the date/time picker? If I use a
custom format, how can I do this AND stick to local date/time display rules?
Thanks,

Robin

Nov 23 '05 #1
9 1851
Robson,

Just set the value of the datetime to a proper date.

By instance roughly typed here

mydatetimepicker1.value = Now

I hope this helps,

Cor
Nov 23 '05 #2
Yes, I'm doing that now to set the intial date, but it just displays the
date part, not the time part. I can set it to show long date, short date or
time, but I want to show Date Time ( DD/MM/YYYY HH:MM:SS or equivalent for
the given locale) in the actual control.

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:ul**************@TK2MSFTNGP09.phx.gbl...
Robson,

Just set the value of the datetime to a proper date.

By instance roughly typed here

mydatetimepicker1.value = Now

I hope this helps,

Cor

Nov 23 '05 #3
Robson,

I assume that you ask how the datetimepicker interacts with the
Iformatprovider as far as I can see does it that only with the custom
paterns from that, and can you not reach your goal because you need the (f
or F) from that (not existing ShortDateTimePattern) however which exist as
"f".

You should can set two datetimepickers however that you would have seen
probably already

Or you can localize your applications and test the currentuicultures and set
accoording to those than the custom paterns (not nice in an age of
globalization in my idea too).

Sorry, I have no other answer for you.

However, I find it a very interesting question and will ask it somewhere
else.

Cor
Nov 23 '05 #4
Thanks Cor, appreciate the help.

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:uS**************@TK2MSFTNGP15.phx.gbl...
Robson,

I assume that you ask how the datetimepicker interacts with the
Iformatprovider as far as I can see does it that only with the custom
paterns from that, and can you not reach your goal because you need the (f
or F) from that (not existing ShortDateTimePattern) however which exist as
"f".

You should can set two datetimepickers however that you would have seen
probably already

Or you can localize your applications and test the currentuicultures and
set accoording to those than the custom paterns (not nice in an age of
globalization in my idea too).

Sorry, I have no other answer for you.

However, I find it a very interesting question and will ask it somewhere
else.

Cor

Nov 23 '05 #5
Robson,
In addition to the other comments.

I normally use 2 datetime picker controls. One for the Date AND one for the
Time.

To keep the two values "in sync" I normally use code similar to:

Private Sub pickerDate_ValueChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles pickerDate.ValueChanged
pickerTime.Value =
pickerDate.Value.Date.Add(pickerTime.Value.TimeOfD ay)
End Sub

Private Sub pickerTime_ValueChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles pickerTime.ValueChanged
Me.labelDateTime.Text = pickerTime.Value.ToString()
End Sub

In the above case I would use pickerTime.Value as the full date time value.
I normally use the following properties on the Time picker:

Format = Custom
CustomFormat = "HH:mm" (for 24 hour:min)
ShowUpDown = True
I normally encapsulate both date time picker controls in a User control that
has properties to simplify the getting & setting values...

--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Robson" <no****@nomeansno.com> wrote in message
news:dl*******************@news.demon.co.uk...
| How do I display the date AND the time in the date/time picker? If I use
a
| custom format, how can I do this AND stick to local date/time display
rules?
|
|
| Thanks,
|
|
|
| Robin
|
|
|
Nov 23 '05 #6
Yes, I thought about this also, but it doesn't seem too clean to me.
Anyway, that seems to be the workaround at least for now.
"Jay B. Harlow [MVP - Outlook]" <Ja************@tsbradley.net> wrote in
message news:ed**************@TK2MSFTNGP11.phx.gbl...
Robson,
In addition to the other comments.

I normally use 2 datetime picker controls. One for the Date AND one for
the
Time.

To keep the two values "in sync" I normally use code similar to:

Private Sub pickerDate_ValueChanged(ByVal sender As System.Object,
ByVal
e As System.EventArgs) Handles pickerDate.ValueChanged
pickerTime.Value =
pickerDate.Value.Date.Add(pickerTime.Value.TimeOfD ay)
End Sub

Private Sub pickerTime_ValueChanged(ByVal sender As System.Object,
ByVal
e As System.EventArgs) Handles pickerTime.ValueChanged
Me.labelDateTime.Text = pickerTime.Value.ToString()
End Sub

In the above case I would use pickerTime.Value as the full date time
value.
I normally use the following properties on the Time picker:

Format = Custom
CustomFormat = "HH:mm" (for 24 hour:min)
ShowUpDown = True
I normally encapsulate both date time picker controls in a User control
that
has properties to simplify the getting & setting values...

--
Hope this helps
Jay [MVP - Outlook]
.NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Robson" <no****@nomeansno.com> wrote in message
news:dl*******************@news.demon.co.uk...
| How do I display the date AND the time in the date/time picker? If I
use
a
| custom format, how can I do this AND stick to local date/time display
rules?
|
|
| Thanks,
|
|
|
| Robin
|
|
|

Nov 23 '05 #7
"Robson" <no****@nomeansno.com> schrieb:
How do I display the date AND the time in the date/time picker? If I use
a custom format, how can I do this AND stick to local date/time display
rules?


\\\
With Me.DateTimePicker1
.Format = DateTimePickerFormat.Custom
.CustomFormat = _
CultureInfo.CurrentCulture.DateTimeFormat.FullDate TimePattern
End With
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 23 '05 #8
Herfried,

Smart,

And to fullfill the asked question in the thread about the shortformat
complete

\\\
.CustomFormat = _
CultureInfo.CurrentCulture.DateTimeFormat.ShortDat ePattern & " " & _
CultureInfo.CurrentCulture.DateTimeFormat.ShortTim ePattern
///

Cor
Nov 23 '05 #9
Superb. Thanks chaps.

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Herfried,

Smart,

And to fullfill the asked question in the thread about the shortformat
complete

\\\
.CustomFormat = _
CultureInfo.CurrentCulture.DateTimeFormat.ShortDat ePattern & " " & _
CultureInfo.CurrentCulture.DateTimeFormat.ShortTim ePattern
///

Cor

Nov 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Angelina | last post by:
Hi, I have got two DateTimePicker's on my form to accept a guest arrival date and departure date.what i want to acheieve is ensure that the DateTimePicker2 (departure) is always greater than...
9
by: Guy | last post by:
I have extended the datetimepicker control to incorporate a ReadOnly property. I have used the new keyword to implement my own version of the value property, so that if readonly == true then it...
1
by: John Smith | last post by:
Hey folks, Got some strange behavior going on here. I have a datetimepicker with showcheckbox = true; If I set Checked=true and set the Text of the datetimepicker, then then the Checked...
0
by: ROG | last post by:
Hi all with help from postings on the web, i have a dateTimePicker in one of my columns in the datagrid. However, when i move in to this column using the arrow keys, it automatically pops up,...
0
by: Sumit | last post by:
Hi all, I have a datetimepicker on my windows form. When the user selects it i check whether the date entered is a Sunday or not & if its not a sunday i want that the control remains on the...
4
by: Jacek Jurkowski | last post by:
.... the minimum date of DateTimePicker is 1753-01-01. How to make DateTime to do not show nothing in its text if this date is the value? I have a form with a field LastLogonDate. If user hasn't...
7
by: Clamara | last post by:
When adding a new record from my form, I pre-set my DateTimePicker's value to System.DateTime.Today Since the "Today" value is used most of the time, the user doesn't need to select a date from...
3
by: Charlie | last post by:
In the top portion of the DateTimePicker, where the value of the date is displayed, how can I detect whether the month or day or year is currently focused, or, if ShowCheckBox = True, whether the...
3
by: Simon Tamman | last post by:
I've come across an interesting bug. I have workarounds but i'd like to know the root of the problem. I've stripped it down into a short file and hope someone might have an idea about what's going...
4
by: jehugaleahsa | last post by:
Hello: We were hoping to allow users to have DateTimePicker value null so that a unused date is stored on a Database. Does the control support this? I am pretty sure it doesn't. How would you...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.