Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
Using alternative formats with TDateTimePicker Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
07-Sep-03
Category
VCL-General
Language
Delphi 5.x
Views
75
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jeff Guidotti

Here is a working example of how to use alternative date formats in the 
TDateTimePicker component for Delphi 5.

Answer:

The problem for me with the TDateTimePicker component, is that it would not only 
allow dates based on the Windows settings for ShortDate and LongDate, but it also 
left gaps in between the separators for dates like ' 2/ 3/01'. This made it look 
terrible.   

I did some research into the problem, and found many "solutions" that did not seem 
to work all the time.  So far, I haven't had any problems with this one, and 
although I tested it in Delphi 5, it should work in some previous versions. 

Simply enter the following line of code into the OnActivate Event for each 
TDateTimePicker on your form.  This will manually set the format, and it should 
remain in place until the form is destroyed. 
1   
2   DateTimePicker1.Perform(DTM_SETFORMAT, 0, DWORD(PCHAR('MM/dd/yyyy')));

The above example assumes that the TDateTimePicker is named DateTimePicker1, and 
you can vary the format by changing the format string ('MM/dd/yyyy'). 

I am not sure what format's are available, and it seems a bit quirky.  I had tried to use 'mm/dd/yyyy', and I wound up with a month of '52'!!!  The above string forces two digit months and days, and four-digit years. 

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC