Autor Beitrag
Phraser
Hält's aus hier
Beiträge: 14



BeitragVerfasst: So 24.11.02 13:59 
Hi!

Ich werkel zur Zeit an einem Stringgrid und würde gerne diverse Zellen einfärben sowie in einigen Zellen die Schriftfarbe ändern.
Im Stringgrid befinden sich zur Zeit Werte und durch ButtonClick rufe ich folgende Anweisung auf:

ausblenden Quelltext
1:
2:
if wettkampf.stringgrid1.Cells[2,2] <> '' then
   canvas.font.color := clred;


Es passiert jedoch nix :(

Wer kann mir helfen?
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: So 24.11.02 15:33 
Hallo,

der Code gehört ins OndrawCell - Ereignis.
Den Text muußt Du aber auch noch ausgeben:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
procedure TForm1.Stringgrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
var s:string;
begin
  with (sender as Tstringgrid) do
    begin
      //Zellhintergrund  (jede zweite Zeile blau)
      if (arow mod 2) = 0 then canvas.brush.color:=clblue
                          else canvas.brush.color:=clwhite;
      if gdfixed in state then canvas.brush.color:=fixedcolor;
      canvas.fillrect(rect);

       //bestimmte Spalte rot darstellen
       if acol=2 then canvas.font.color:=clred
                     else  canvas.font.color:=clblack

      canvas.textout(rect.left+2,rect.top+2,s);
    end;
end;


Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)