Solved

Delphi2010: unable to modfiy time in a datetimepicker component

Posted on 2010-11-24
17
991 Views
Last Modified: 2012-05-10
hi all,

i would like to let a datetimepicker show date and times. And they must be editable.

after i ran the application, it is only possible to choose differt date/day, but i could not edit the hh:mm:ss.  any idea?

following are the codes i use:

procedure TForm1.FormCreate(Sender: TObject);
begin
  DateTimePicker1.Format := 'd MMM,yyyy hh:mm:ss';
end;

thanks,

wantime
0
Comment
Question by:wantime
  • 8
  • 4
  • 3
  • +2
17 Comments
 
LVL 24

Accepted Solution

by:
jimyX earned 250 total points
ID: 34204322
DateTimePicker seems to be not supporting to show the date and the time all together and give you the ability the change the time, you should separate them in two sets:

DateTimePicker1 to support the date and DateTimePicker2 to support the time.
0
 
LVL 24

Expert Comment

by:jimyX
ID: 34204447
In that format you can change either the date or the time but not both, and that's based on the "DateTimePicker.kind". If it is dtkTime the time is changeable but the date is not, and if it is dtkDate then the date is changeable but the time is not.
 
0
 

Author Comment

by:wantime
ID: 34204827
so, the only way is to use two DateTimePicker component to support both date and time?

it looks a litte bit weird...

is it impossible to combinate both in one box?
0
 
LVL 24

Expert Comment

by:jimyX
ID: 34204846
You can combine them, but you will be able to change only one, either the date or the time.
0
 
LVL 24

Expert Comment

by:jimyX
ID: 34205046
I will look for a third party component that can support both date and time.
Will get back to you.
0
 

Author Comment

by:wantime
ID: 34205098
thanks, i am also looking for it.
0
 
LVL 24

Expert Comment

by:jimyX
ID: 34205794
After searching for that, found "Adrock DateTime Suite" which is old (Delphi 5):

http://www.adrock.com/Products/DelphiComponents.aspx

But the good thing it's free and source code provided. I couldn't manage to install all the components and get it working, so try it, if you want to give it a shot.

But I think using two Datetimepickers is going to be your option at the end.

0
 
LVL 36

Expert Comment

by:Geert Gruwez
ID: 34206077
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 19

Expert Comment

by:Thommy
ID: 34206097
I assent to jimyX's solution:
Use 2 DATETIMEPICKERs, one with dtkDate kind and the other one dtkTime Kind.


You can put together the date and time as follows...

uses
DateUtils;

var
myDateTime :TDatetime;
begin
myDateTime := EncodeDateTime(YearOf(DateTimePicker_Date.Date), MonthOf(DateTimePicker_Date.Date), DayOf(DateTimePicker_Date.Date), HourOf(DateTimePicker_Hour.Time), MinuteOf(DateTimePicker_Hour.Time), SecondOf(DateTimePicker_Hour.Time),0);
0
 
LVL 19

Assisted Solution

by:Thommy
Thommy earned 125 total points
ID: 34206231
You can also use 3rd party component ZVDateTimePicker

ZVDateTimeControls Package
http://wiki.freepascal.org/ZVDateTimeControls_Package#TZVDateTimePicker

Its property kind can have 3 values: dtkDate, dtkTime and dtkDateTime

dtkDateTime allows to change date and time together...
0
 
LVL 19

Expert Comment

by:Thommy
ID: 34206356
Ooops, I've seen that ZVDateTimeControls is for FreePascal!!!

Sorry...
0
 
LVL 32

Assisted Solution

by:ewangoya
ewangoya earned 125 total points
ID: 34210680

@wantime

This issue is fixed in Delphi2010 if you are going to upgrade some time in the near future

Otherwise
You can try TDateTimePickerEX which is a descendant of TDateTimePicker and is free with code and supports upto Delphi2009
Geert_Gruwez already listed it
http://www.be-precision.com/products/precision-utils/
0
 

Author Comment

by:wantime
ID: 34221670
thanks. i have taken a look at http://www.be-precision.com/products/precision-utils/

but i don't know how to use the .pas and .dcr file.

i have not yet found out how to add the new TDateTimePicker to toolkits.
0
 
LVL 24

Expert Comment

by:jimyX
ID: 34221702
In the Delphi IDE click File -> New Package -> in the right hand side, go to "contains" folder in "Project Manager" and right click 'add' then look for "DTPEx.pas" that you downloaded, then right click package.bpl and "install".
0
 
LVL 24

Expert Comment

by:jimyX
ID: 34221838
For easy reference:

1.JPG
2.JPG
3.JPG
4.JPG
0
 

Author Comment

by:wantime
ID: 34257152
thanks.

in  DTPEx.pas i saw the following commentar:

"The complete source code remains property of the author and may not be distributed,
published, given or sold in any form as such. "

the thing is the product i am developing will be sold. does it mean that i am not allowed to use these codes in my product?
0
 
LVL 24

Assisted Solution

by:jimyX
jimyX earned 250 total points
ID: 34257282
That comment is talking about using the source code of the DTPEx component.

It also says:
"This unit can be freely used in any application."
So if you are not distributing the source code of the component along with your project, I do not see any violation here.

But if you are going to distribute the source code of the component then, as per the Author comment:

"No parts of the source code can be included in any other component or application without written authorization of the author."

Mainly that comment is for plagiarism violations. If in doubt just write to the author requesting permission:

info@be-precision.com
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now