Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

DateTimePicker question

Posted on 2010-08-20
3
Medium Priority
?
419 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
[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
  • 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 38

Accepted Solution

by:
Geert Gruwez earned 2000 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

636 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