Autor Beitrag
MisterBum83
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 245
Erhaltene Danke: 2

WIN XP
Delphi 6
BeitragVerfasst: Mo 19.09.05 11:52 
Hallo,
wie könnte man vorgehen, wenn man eine Treeview als Kalender nehmen möchte,
d.h. der Hauptknoten als Jahr, darunter als weitere Knoten die Monate und darunter wieder als weitere Knoten die Tage.

z. B. so:

- Jahre
+ 2004
- 2005
+ Januar
+ Februar
- März
1. Do
2. Fr
und so weiter
+ 2006
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 19.09.05 17:05 
Moin!

user profile iconMisterBum83 hat folgendes geschrieben:
wie könnte man vorgehen, wenn man eine Treeview als Kalender nehmen möchte,
d.h. der Hauptknoten als Jahr, darunter als weitere Knoten die Monate und darunter wieder als weitere Knoten die Tage.

Indem man diese Elemente anlegt. :wink:

Was genau ist denn jetzt deine Frage... :gruebel:

cu
Narses
MisterBum
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 107



BeitragVerfasst: Mo 19.09.05 18:40 
Meine Frage ist genau:
Das ich das nicht von Hand im Quellcode eingeben muss, sondern das Programm das automatisch macht, sprich den aktuellen Kalender auslesen und ich nicht für jedes Jahr 365 Tage eingeben muss...
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Mo 19.09.05 20:04 
Das sollte kein Problem darstellen. Im Datentyp tDateTime werde die Zeiten in (gebrochenen) Tagen gespeichert. Du kannst also eine tDateTime Variable auf das gewünschte Startdatum setzen und dich dann in einer Zählschleife Tag für Tag voran arbeiten. Jetzt musst du nur noch bedingungen für neuer Monat und neus Jahr einfügen und Fertig.

Du solltest in der Delphi Hilfe bei tDateTime anfangen von da aus solltest du zu Datumsfuntionen wie z.B. EncodeDate kommen welche dir das arbeiten mit tDateTime vereinfachen.

Gruß
Klabautermann
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 19.09.05 20:29 
Moin!

Meinst du sowas?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
var
  Year, Month: TTreeNode;
  i,last_i: TDate;

begin
  TreeView1.Items.Clear;
  i := EncodeDate(YearOf(Now),1,1); // 1.1. im aktuellen Jahr
  last_i := 0;
  Year := TreeView1.Items.Add(NIL,FormatDateTime('yyyy',i));
  repeat
    if (MonthOf(i) <> MonthOf(last_i)) then
      Month := TreeView1.Items.AddChild(Year,FormatDateTime('mmmm',i));
    TreeView1.Items.AddChild(Month,FormatDateTime('d. dddd',i));
    last_i := i;
    i := IncDay(i);
  until (YearOf(i) <> YearOf(last_i));
end;

cu
Narses
MisterBum
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 107



BeitragVerfasst: Di 20.09.05 09:50 
Super Jungs,
genau das meinte ich!!!

Vielen vielen Dank...

MisterBum