Solved

DateTimePicker question

Posted on 2010-08-20
3
413 Views
Last Modified: 2012-05-10
Hi,

I have a datetimepicker on my form, that I don't get on the current date.
I have put: GotoDatePicker.Date := Date; in the OnShow-event, but the
datetimepicker gets the date of my component JvDays1 from JediVCL.
I have put some code in the code-section.

Who knows the answer and is willing to help me?

Greetings, Peter Kiers
procedure TMainForm.FormShow(Sender: TObject);

var

  ResName : String;

begin

  GotoDatePicker.Date := Date;

 // GotoDatePicker.Date := EncodeDate(2002, 1, 1);

  TimeIncCombo.ItemIndex := 1;

  ModeCombo.ItemIndex := 0;

  DaysCombo.ItemIndex := 6;

  With SchedulesQuery do

    try

      Open;

      First;

      While not EOF do

        Begin

          ResName := SchedulesQuery.FieldByName('SchedName').AsString;

          ResourceCombo.Items.Add(ResName);

          VisibleResources.ResourcesCheckList.Items.Add(ResName);

          Next;

        End;

      Close;

    except

      on E:EDBEngineError do

      begin

        ShowMessageFmt('%s:'#13#10'Try moving the database to a shorter path.',[E.Message]);

        Application.Terminate;

        Exit;

      end;

    end;

  ResourceCombo.ItemIndex := 0;

  VisibleResources.ResourcesCheckList.Checked[0] := True;

  TFDays.Template.CompNames.Add(VisibleResources.ResourcesCheckList.Items[0]);

  ResourceComboChange(nil);

  DaysComboChange(nil);

  ModeComboChange(nil);

  //GotoDatePicker.Date := EncodeDate(2002, 1, 1);

  GotoDatePickerChange(nil);

  TimeIncComboChange(nil);

end;

(*------------------------------------------------------*)

procedure TMainForm.GotoDatePickerChange(Sender: TObject);

begin

  TFDays.GotoDate(GotoDatePicker.Date);

  TFWeeks.DisplayDate := GotoDatePicker.Date;

  TFMonths.DisplayDate := GotoDatePicker.Date;

end;

Open in new window

0
Comment
Question by:peterkiers
  • 2
3 Comments
 
LVL 1

Author Comment

by:peterkiers
ID: 33488778
When I remove the //  at line: GotoDatePicker.Date := EncodeDate(2002, 1, 1);
and put // at line: GotoDatePicker.Date := Date;
Then it works great but for at startup I get the date 1-1-2002 and not the current date.

Peter Kiers

0
 
LVL 37

Accepted Solution

by:
Geert Gruwez earned 500 total points
ID: 33488923
put initialisation in formcreate, not formshow

formshow is for every time a form is shown
like hide/show/hide/show ... etc

tried this ?
JvDays1.Date := Date;
0
 
LVL 1

Author Comment

by:peterkiers
ID: 33488928
Yes, it works. Thanks Geert.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Thread safe  opinion 7 126
How to disable mouse scroll in a combo box field within a Delphi cxGrid 4 110
Using idhttp to login to instagram 2 76
CheckListBox usage 3 49
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…
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…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

914 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

14 Experts available now in Live!

Get 1:1 Help Now