Autor Beitrag
Passi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: So 02.01.05 22:23 
Hi,

wie kann man die Schriftfarbe einer bestimmten Zelle im StrinGrid ändern?
Die gesamte Schriftfarbe eines StringGrids zu ändern ist ja kein Problem..., aber nur eine bestimmte Zelle in einer bestimmten Reihe??
Die Schriftfarbe soll sich aber nicht erst beim markieren einer Zelle ändern, sondern von Anfang an, also nichts mit OnDrawCell.
grayfox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 800

win98, winXP
D4 Standard; D6 Personal
BeitragVerfasst: So 02.01.05 22:35 
hallo passi!

mit OnDrawCell liegst du goldrichtig. es funktioniert bei allen zellen, nicht nur bei der gerade markierten.
beispiele über die richtige anwendung findest du hier im forum schon zuhauf - einfach danach suchen ;)

mfg, stefan
Passi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: So 02.01.05 22:54 
Ok, ich sollte erst nachdenken, dann fragen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
with (sender as Tstringgrid) do
    begin
      if (acol=9) and (Pos('-',cells[9,arow])<>0) then canvas.font.color:=clred
       else if (acol=10) and (Pos('-',cells[10,arow])<>0) then canvas.font.color:=clred
       else if (acol=9) and (Pos('-',cells[9,arow])=0) then canvas.font.Color:=clgreen
       else if (acol=10) and (Pos('-',cells[10,arow])=0) then canvas.font.Color:=clgreen
       else canvas.font.color:=clblack;

      if (arow mod 2) = 0 then canvas.brush.color:=clgray
                          else canvas.brush.color:=clwhite;
      if gdfixed in state then
        begin
          canvas.brush.color:=fixedcolor;
          canvas.Font.color := clblack;
        end;

      if gdSelected in State then canvas.Brush.Color := RGB(225, 225, 255);

      Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, Cells[ACol, ARow]);
    end;


so hab ich es nun gelöst bekommen.

Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt.
grayfox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 800

win98, winXP
D4 Standard; D6 Personal
BeitragVerfasst: So 02.01.05 23:10 
Zitat:
Ok, ich sollte erst nachdenken, dann fragen:


oder, wie wir so schön sagen:

Zitat:
durchs reden kommen die leut zam (= zusammen) ;)


hauptsache, dass dein stringgrid nun doch noch bunt geworden ist.

mfg, stefan