Solved

Delphi2010: unable to modfiy time in a datetimepicker component

Posted on 2010-11-24
17
1,050 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses
Course of the Month4 days, 11 hours left to enroll

635 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