Autor Beitrag
AlexBegin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 39



BeitragVerfasst: Mo 17.03.08 09:07 
Ich möchte das Datum mittels Strings eines MonthCalendar verändern.

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
procedure TForm3.FormShow(Sender: TObject);
var
Datum, Tag, Monat, Jahr: String;

begin
  Tag := '01.';
  if Form1.ComboBox1.Text = 'Januar' then
    begin
      Monat := '01.';
    end;
  if Form1.ComboBox1.Text = 'Februar' then
    begin
      Monat := '02.';
    end;
  if Form1.ComboBox1.Text = 'März' then
    begin
      Monat := '03.';
    end;
  if Form1.ComboBox1.Text = 'April' then
    begin
      Monat := '04.';
    end;
  if Form1.ComboBox1.Text = 'Mai' then
    begin
      Monat := '05.';
    end;
  if Form1.ComboBox1.Text = 'Juni' then
    begin
      Monat := '06.';
    end;
  if Form1.ComboBox1.Text = 'Juli' then
    begin
      Monat := '07.';
    end;
  if Form1.ComboBox1.Text = 'August' then
    begin
      Monat := '08.';
    end;
  if Form1.ComboBox1.Text = 'September' then
    begin
      Monat := '09.';
    end;
  if Form1.ComboBox1.Text = 'Oktober' then
    begin
      Monat := '10.';
    end;
  if Form1.ComboBox1.Text = 'November' then
    begin
      Monat := '11.';
    end;
  if Form1.ComboBox1.Text = 'Dezember' then
    begin
      Monat := '12.';
    end;
  Jahr := RightStr(DateToStr(date),4);
  Datum := Tag + Monat + Jahr;
  MonthCalendar1.Date := StrToDate(Datum);
end;



Leider erscheint immer wieder die folgende Fehlermeldung:

Zitat:

Im Projekt ... ist eine Exception der Klasse ECommonCalendarError mit der Meldung 'Der ausgewählte Bereich des Kalenders kann nicht gesetzt werden' ausfgetreten.


Ich habe hier im Forum schon gesucht, aber bis jetzt noch nichts Richtiges gefunden. Könnt ihr mir vielleicht bei meinem Problem weiter helfen. Im voraus sage ich schon einmal Danke

Bis dann Alex

Moderiert von user profile iconNarses: Code- durch Delphi-Tags ersetzt
Andreas Schilling
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 128
Erhaltene Danke: 1

WIN XP, WIN 7
Delphi 5 Ent, Delphi 2007 Pro, XE4
BeitragVerfasst: Mo 17.03.08 10:06 
Was passiert wenn du
ausblenden Delphi-Quelltext
1:
  MonthCalendar1.Date := StrToDate('01.01.2008');					

im Quelltext verwendest statt des zusammmengebastelten String?
AlexBegin Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 39



BeitragVerfasst: Mo 17.03.08 12:14 
Für Andreas:
Dann kommt die Fehlermeldung 'Inkompatible Typen: TDate und string'


Ich habe nun den Fehler gefunden. Habe im Objektinspektor den MultiSelect auf True gesetzt, da ich im MonthCalendar mehrere Tagen auswählen muss. Und da liegt der Hund begraben. Wenn MultiSelect auf True gesetzt wird und man will das Datum wie ich ändern, kommt es zur Fehlermeldung. Nun habe ich im Objektinspektor MultiSelect auf False gesetzt. Im Programm habe ich das Ändern des Datums und anschließendes setzen des MultiSelect durch folgendes ersetzt.

ausblenden Delphi-Quelltext
1:
2:
MonthCalendar1.Date := EncodeDate(Jahr,Monat,Tag);
MonthCalendar1.MultiSelect := True;


Moderiert von user profile iconNarses: Code- durch Delphi-Tags ersetzt