Solved

Delphi2010: unable to modfiy time in a datetimepicker component

Posted on 2010-11-24
17
1,010 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 37

Expert Comment

by:Geert Gruwez
ID: 34206077
0
 
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:Ephraim Wangoya
Ephraim Wangoya 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 Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Show Listview image from database (String field) 5 145
DBGrid or StringGrid ? 6 120
FMX TEdit KeyUp handler detecting  "enter" key 4 39
Get weeknumber and year from date 4 27
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

749 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