From: alanglloyd@aol.com (AlanGLLoyd) Subject: Re: DateTimePicker must always show a date? Date: 11 Mar 2000 00:00:00 GMT Message-ID: <20000311142623.08669.00000479@nso-fa.aol.com> References: Organization: AOL, http://www.aol.co.uk Newsgroups: comp.lang.pascal.delphi.misc X-Admin: news@aol.com In article , "Ellinor Jensen" writes: >I use DateTimePicker for 'Recieved' date, 'Started on' date and 'Finished' >date. >The challenge is that I don't want a value showed in theese pickers before >one is selected. >This seems impossible? I want a blank edit window when no date is selected. >Of course I could use the visible event, but this will screw up the look and >intuitive use. > >Anyone have a functionally solution for this ? > >I'm not experienced enough to override the DateTimePicker component, so if >this is the solution - I will need the code to put in. > Use the DateTime_SetFormat API macro (put CommCtrl in the uses clause) to set the date to blank or a message :- DateTime_SetFormat(DateTimePicker1.Handle, '''Choose a date'''); Note the three single apostrophes at each end to leave one in the string to ensure that the characters are not interpreted as hours (h), seconds (s), or days (d). If you want a blank, just a blank string would do. Then in the DateTimePicker OnCloseUp event handler set the format to what you want when a date has been selected, and the DTP will show the selected date :- procedure TForm1.DateTimePicker1CloseUp(Sender: TObject); begin DateTime_SetFormat(DateTimePicker1.Handle, 'd MMM yyyy'); end; That would set it to "11 Mar 2000" for today, the codes are rather like MS Excel but note "M" for month, "m" is for minute, all others are lower case. "d" for single or double figures for date, "dd" for ledaing zero, "ddd" for "Mon", "Tues", "Wed" etc., "dddd" for "Monday", "Tuesday", "Wednesday" etc. Months are similar. Alan Lloyd alanglloyd@aol.com