Autor Beitrag
arnydaniel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 80

hoffentlich bald Linux
Delphi 6
BeitragVerfasst: Mo 14.11.05 21:41 
Hi,

Hat einer ne Idee, wie ich die Tabelle von dem Angehängten Bild umsetzten kann?
(Name, Verein, die obere Zeile der Doppelzeilen und Punke gesamt kommen aus ner Datenbank und die unter Doppelspalte muss erst noch berechnet werden)

Danke
Gruß
Einloggen, um Attachments anzusehen!
_________________
Wenn jeder nur an sich denkt, wird an jeden gedacht.
J.Borchert
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 150

WIN10
XE2 Professional
BeitragVerfasst: Di 15.11.05 19:57 
So echt weiss wohl niemand, was du mit umsetzen meinst.

Ich würde die Tabelle in HTML erstellen. Rechnen lassen kann man dann mit Java Script und wenn man INPUT-Elemente benutzt kann sogar Interaktivität drin sein.
Außerdem kann jeder DAU das Dokument anzeigen und drucken usw.


mfG Jürgen

[DAU: dümmster anzunehmender user]
Amateur
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 777

(Win98, WinMe) WinXP Prof
D3 Prof, D6 Pers, D2k5 Pers., Turbo C++ Explorer
BeitragVerfasst: Di 15.11.05 20:22 
nur ma so wir sind hier in nem delphi forum.
wieso schlägste dann html vor auch wensn damit viel besser ist. wenn er html wolen würde hätte er in einem entsprechenden forum gepostet...
ich sag ma ne stringlist oder so oder ne datenbank

_________________
"Kein dummes Gerede. Kein Rumrätseln. Denkt an nichts anderes mehr, nur noch an das, was vor euch liegt. Das ist die wahre Herausforderung. Ihr müßt euch vor euch selbst schützen, Leute." (Rennes in "Cube")
Beiträge: >700
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Di 15.11.05 20:25 
Bei solch komplexen Tabellen wirst Du um's selber zeichnen nicht drum rum kommen.

Fasse jede Datenzeile als eine Zeile der Grid auf und unterteile sie dann Vertikal im OnOwnerDraw-Ereignis. Die Mehrfachspalten erzeugst Du am besten auf die gleiche Art und Weise ...

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
arnydaniel Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 80

hoffentlich bald Linux
Delphi 6
BeitragVerfasst: Di 15.11.05 20:59 
Um mal ganz ehrlich zu sein: Ich hab keine Ahnung wie ich das nun umsetzten soll.
Wie soll das gehen mit dme selbst zeichen?

_________________
Wenn jeder nur an sich denkt, wird an jeden gedacht.
arnydaniel Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 80

hoffentlich bald Linux
Delphi 6
BeitragVerfasst: Mi 16.11.05 18:40 
Ok, hab jetzt ein Tutorial gefunden.

da steht folgende Zeile drin:
ausblenden Delphi-Quelltext
1:
grid.Canvas.Font.Assign(EigenschaftenGrid[ACol, ARow].Schrift)					


(Grid ist der name meines Stringgrids und eigensch.....schrift bekomm ich aus einem FontDialog)

Warum sagt der mir da dass TScreen nicht zu TFont zugewiesen werden kann??

Gruß

_________________
Wenn jeder nur an sich denkt, wird an jeden gedacht.
arnydaniel Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 80

hoffentlich bald Linux
Delphi 6
BeitragVerfasst: Fr 18.11.05 10:20 
Ok, dann stell ich die Frage mal anderst:
Wo find ich ein Tutorial zu String grid? (außer dem: home.arcor.de/hardcoders/ delphi/tutorials/download/stringgrid.pdf )
(Das Tutorial muss nicht sehr tiefgreifen sein, ich will nur jede 2. Zeile einfärben und einen Zeilenumbruch in den Zellen haben)

Oder: warum funktioniert der Quellcode aus dem eben genannten Tut. bei mir nicht?

Gruß

_________________
Wenn jeder nur an sich denkt, wird an jeden gedacht.
J.Borchert
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 150

WIN10
XE2 Professional
BeitragVerfasst: Fr 18.11.05 16:13 
Folgender Code färbt jede zweite Zeile rot. Dazu wird das OnDrawCell Event verwendet.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, 
 ARow: Integer; Rect: TRect; State: TGridDrawState);
begin
 if not Odd(ARow) and not (gdFixed in State) then
   with StringGrid1 do
   begin
     Canvas.Brush.Color := clRed;
     Canvas.FillRect(Rect);
     Canvas.TextOut(Rect.Left+2, Rect.Top+2, Cells[ACol, ARow]);
   end;
end;


Das ist nur ein Beispiel aus:

www.dsdt.info/eh/

mfG Jürgen

_________________
Wer immer macht was er schon kann, bleibt immer das, was er schon ist. "H.Ford"
arnydaniel Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 80

hoffentlich bald Linux
Delphi 6
BeitragVerfasst: Fr 18.11.05 17:06 
Ich hab jetzt mal ne kleine Beispielanwendung gemacht - ist im Anhang.

3 Fragen dazu:
1. Wie kann ich es erreichen, dass ich in einer Zelle einen Zeilenumbruch hinbekommen? (Zeile 54 im Code) - WordBreak ist natürlich mit drin
2. Wieso wird in Zeile 60 der Wert nicht richtig angezeigt?
3. Wie kann ich die Schrift horizontal ausrichten?

Danke
Gruß
Einloggen, um Attachments anzusehen!
_________________
Wenn jeder nur an sich denkt, wird an jeden gedacht.
J.Borchert
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 150

WIN10
XE2 Professional
BeitragVerfasst: Fr 18.11.05 21:52 
Für den Umbruch ein Beispiel:
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:
procedure StringGridAlignment(Grid: TStringGrid; Rect: TRect; ACol, ARow: Integer;
  Alignment: TAlignment; LineBreak: Boolean);
var
  TextOut: String;
begin
  if (aRow<>Grid.Row)and(aCol>0) then Grid.Canvas.Brush.Color := clwhite;
  if (ARow mod 2 = 0)and(aRow>0) then
  begin // jede zweite Zeile einfärben
   Grid.Canvas.Brush.Color:=clMoneyGreen;
  end;
  if (aRow=Grid.Row)and(aCol>0) then
    Grid.Canvas.Brush.Color := clYellow; // aktuelle Zeile hervor
  Grid.Canvas.FillRect(Rect);

  TextOut := Grid.Cells[ACol,ARow];
  Rect.Left:=rect.Left+2;
  Rect.Top:=Rect.Top+2;
  Rect.Right:=Rect.Right-2;
  if LineBreak = false then
  begin
    if Alignment = taLeftJustify then
      DrawText(Grid.Canvas.Handle, PChar(TextOut), StrLen(PChar(TextOut)), Rect,DT_LEFT);
    if Alignment = taCenter then
      DrawText(Grid.Canvas.Handle, PChar(TextOut), StrLen(PChar(TextOut)), Rect,DT_CENTER);
    if Alignment = taRightJustify then
      DrawText(Grid.Canvas.Handle, PChar(TextOut), StrLen(PChar(TextOut)), Rect,DT_RIGHT);
  end
  else
  begin
    if Alignment = taLeftJustify then
      DrawText(Grid.Canvas.Handle, PChar(TextOut), StrLen(PChar(TextOut)),
      Rect,DT_LEFT+DT_WORDBREAK);
    if Alignment = taCenter then
      DrawText(Grid.Canvas.Handle, PChar(TextOut), StrLen(PChar(TextOut)), Rect,
      DT_CENTER+DT_WORDBREAK);
    if Alignment = taRightJustify then
      DrawText(Grid.Canvas.Handle, PChar(TextOut), StrLen(PChar(TextOut)), Rect,
      DT_RIGHT+DT_WORDBREAK);
  end;
end;


Wenn ich mich nicht irre, ist hier bei dem Code-Schnipsel etwas bei für vertikale Schrift

ausblenden 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:
procedure TForm2.sg1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
var  lf: TLogFont;  tf: TFont;
begin
  with sg1.Canvas do
  begin  Font.Name:='MS Sans Serif';    Font.Size:=10; //
         Font.Color:=gd[ACol, ARow].FontColor;
         Font.Style:=[];
         tf:=TFont.Create;
         try tf.Assign(Font);      GetObject(tf.Handle, sizeof(lf), @lf);
             lf.lfEscapement:=900; lf.lfOrientation:=0;
             tf.Handle:=CreateFontIndirect(lf);    Font.Assign(tf);
         finally      tf.Free;    end;

        if  (State = [])and
            (gd[aCol,aRow].RealDate<>'')
           then Brush.Color  := gd[ACol, ARow].Color;

        if ((ARow=2)or(ARow=11)or(ARow=20))or
           ((ACol=0)or(ACol=8)or(ACol=16)or(ACol=24)) then
          begin

            Brush.Color:=$00ACE0FD; Font.Color:=clBlue;
            Font.Style:=[fsBold];   FillRect(Rect);
          end;
         Rect.Left:=rect.Left+2;         Rect.Top:=Rect.Top+2;
         Rect.Right:=Rect.Right-2;       FillRect(Rect);
         DrawText(Handle, PChar(sg1.Cells[ACol, ARow]),
                  StrLen(PChar(sg1.Cells[ACol, ARow])), Rect,DT_CENTER);


Muß jetzt zur Arbeit Tschüss erstmal...hatte noch keine Zeit für deinen Quelltext

_________________
Wer immer macht was er schon kann, bleibt immer das, was er schon ist. "H.Ford"
arnydaniel Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 80

hoffentlich bald Linux
Delphi 6
BeitragVerfasst: Fr 18.11.05 21:57 
Danke erstmal soweit. Aber es wäre super, wenn Du meinen Quelltext nochmal ansehen würdest.

_________________
Wenn jeder nur an sich denkt, wird an jeden gedacht.
J.Borchert
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 150

WIN10
XE2 Professional
BeitragVerfasst: Fr 18.11.05 22:01 
Wenn Du defaultColwidth kleiner machst, wird der Umbruch realisiert. also erst wenn es notwendig wird. (mit Leerstellen auffüllen)

_________________
Wer immer macht was er schon kann, bleibt immer das, was er schon ist. "H.Ford"
J.Borchert
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 150

WIN10
XE2 Professional
BeitragVerfasst: Fr 18.11.05 22:14 
Im OnDraw bei DrawText sind die Cols und Rows in der Reihenfolge vertauscht.

Merkt man, wenn man im laufenden Programm nach unten scrolt und wieder hoch.

_________________
Wer immer macht was er schon kann, bleibt immer das, was er schon ist. "H.Ford"
arnydaniel Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 80

hoffentlich bald Linux
Delphi 6
BeitragVerfasst: Sa 19.11.05 09:34 
Prima danke soweit nochmal.

Aber eine kkleine Frage bleibt da noch: Wie kann ich den Text vertikal ausrichten. Hab mal recherchiert und hab DT_VCenter gefunden, es klappt aber nicht.

_________________
Wenn jeder nur an sich denkt, wird an jeden gedacht.
arnydaniel Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 80

hoffentlich bald Linux
Delphi 6
BeitragVerfasst: Sa 19.11.05 16:20 
OK, ich hab jetzt inzwischen herrausgefunden, dass DT_VCenter nur in Verbindung mit DT_Singleline funktioniert.
Kann ich aber auch einen zwei zeiligen Text vertikal ausrichten?

_________________
Wenn jeder nur an sich denkt, wird an jeden gedacht.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 19.11.05 16:56 
Mit TCanvas.TextWidth, TCanvas.TextHeight und TCanvas.TextExtend kannst Du die Textbreite, Zeilenhöhe, oder beides gleichzeitig abfragen.

(Zellhöhe - TextHöhe) div 2 ist der Vertikale Offset zum Zentrieren.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.