Autor Beitrag
raiha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 152



BeitragVerfasst: Mi 17.08.05 13:30 
Hi,

gibt es eine Möglichkeit Werte innerhalb eines DB Grids formatiert darzustellen?

Konkret bedeutet das bei mir das ich ab der 2ten Stelle runden will. Aber eben nur im Grid und nicht in der dahinterliegenden DB-Tabelle.


Danke Rainer
alex517
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 60


D7Ent, FB, FIBPlus
BeitragVerfasst: Mi 17.08.05 15:18 
Eine spezielle Formatierung im DBGrid kann durch die Darstellung mit DrawText im OnDrawColumnCell
des DBGrids erreichen.

Aber vielleicht reicht ja die Formatierung durch das GetText-Ereignis des entsprechenden Feldes.

z.B.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.Query1RechBetragGetText(Sender: TField; var Text: String; DisplayText: Boolean);
begin
  if DisplayText then
    Text := format('%.2n', [Sender.AsFloat])
  else
    Text := Sender.AsString;
end;

alex
uwewo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 154



BeitragVerfasst: Mi 17.08.05 18:22 
Hi Raiha,

ich vermute mal das Du dein DBGrid mit einer Tabelle
verbunden hast!
Nach Doppelklick auf die Tabelle, kannst Du mit der rechten Maustaste deine gewünschten Felder hinzufügen.

Klicke auf dein Feld das Du formatieren möchtest und
gebe im Objektinspektor bei Displayformat #,###.#0 ein,
dann formatiert auch dein DBGrid das Feld.

Das Komma steht für das Tausender Trennzeichen,
der Punkt für Das Komma

Bsp:

#,###.#0 = 1.000,10

Hoffe das hilft Dir

Uwe
alex517
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 60


D7Ent, FB, FIBPlus
BeitragVerfasst: Mi 17.08.05 18:30 
Überredet, man kanns auch einfach machen.:oops:
the_immortal
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 78



BeitragVerfasst: Mo 17.10.05 17:20 
Ich verwende ein Query und ein DBGrid und ich möchte eine bestimmte Kolonne speziel formatieren!

Lösung?
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mo 17.10.05 17:27 
Sieh dir an, was user profile iconuwewo geschrieben hat.
Alternativ kannst du dir meine Komponente "Feld-Formatierer" von meiner HP zu Gemüte führen.
the_immortal
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 78



BeitragVerfasst: Mo 17.10.05 17:34 
user profile iconjasocul hat folgendes geschrieben:
Sieh dir an, was user profile iconuwewo geschrieben hat.
Alternativ kannst du dir meine Komponente "Feld-Formatierer" von meiner HP zu Gemüte führen.


Scheint jedoch nur für Integers zu sein? Ich möchte einen String bearbeiten!
the_immortal
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 78



BeitragVerfasst: Mo 17.10.05 17:46 
user profile iconthe_immortal hat folgendes geschrieben:
user profile iconjasocul hat folgendes geschrieben:
Sieh dir an, was user profile iconuwewo geschrieben hat.
Alternativ kannst du dir meine Komponente "Feld-Formatierer" von meiner HP zu Gemüte führen.


Scheint jedoch nur für Integers zu sein? Ich möchte einen String bearbeiten!


OnGetText ist die Lösung :)