Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi StringGrid nicht neuzeichnen (https://www.delphipraxis.net/49370-stringgrid-nicht-neuzeichnen.html)

Sushibb 10. Jul 2005 12:23


StringGrid nicht neuzeichnen
 
Hallo,


hab in nem kleinen Tool n Stringgrid, wo einzelne Zellen eine bestimmte Schriftfarbe bekommen, wenn eine Bedingung erfüllt ist. Leider zeichnet er das Grid dauernd neu und somit frisst der meist 80% mein CPU-Leistung. Jetzt hab ich versucht mit
Delphi-Quellcode:
StringGrid1.OnDrawCell:=nil;
das neuzeichnen zu verhindern, allerdings klappt das nicht wie gewünscht,sondern die Farben erscheinen nur nicht mehr.

Wie kann ich dem Prog verbieten und erlauben, das Grid neuzuzeichnen, und zwar wenn ich das will?

Keldorn 10. Jul 2005 12:32

Re: StringGrid nicht neuzeichnen
 
wie sieht denn dein code bisher aus? Im Ondracell darfst du keine Zelltext neu setzen, sonst wirds wieder aufgerufen.

Mfg Frank

Sushibb 10. Jul 2005 12:38

Re: StringGrid nicht neuzeichnen
 
Delphi-Quellcode:
procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
var payback,i,multip:integer;
begin
 if RadioButton1.Checked then multip:=1 else multip:=2;
 If (ACol>=3) and (ACol<11) then
 begin
  try
    payback:=StrToInt(StringGrid1.Cells[ACol+1,ARow]);
  except
    payback:=0;
  end;
  If payback>=150*multip then
  begin
    StringGrid1.Font.Color := clgreen;
//    StringGrid1.Canvas.FillRect(Rect);
  end
  else if (payback<150*multip) and (payback>=120*multip) then
  begin
    StringGrid1.Font.Color := clolive;
//    StringGrid1.Canvas.FillRect(Rect);
  end
  else if (payback<120*multip) and (payback>=90*multip) then
  begin
    StringGrid1.Font.Color := clred;
//    StringGrid1.Canvas.FillRect(Rect);
  end
  else StringGrid1.Font.Color:=clBlack;
 end
 else StringGrid1.Font.Color:=clblack;
 If (Acol=12) and (arow=20) then StringGrid1.OnDrawCell:=nil; //Versuch, dass neuzeichnen zu verbieten
end;
Eigentlich setze ich nur die Textfarbe oder?
Der Versuch der Unterbindung (Kommentar im Code) wird beim Buttonklick dann wieder erlaubt:

Delphi-Quellcode:
  StringGrid1.OnDrawCell:=StringGrid1DrawCell;

Christian Seehase 10. Jul 2005 12:43

Re: StringGrid nicht neuzeichnen
 
Moin Sushibb,

das hat zwar leider nichts mit Deinem Problem zu tun:
Mach mal aus
Delphi-Quellcode:
try
  payback:=StrToInt(StringGrid1.Cells[ACol+1,ARow]);
except
  payback:=0;
end;
lieber
Delphi-Quellcode:
  payback:=StrToIntDef(StringGrid1.Cells[ACol+1,ARow],0);


Alle Zeitangaben in WEZ +1. Es ist jetzt 02:54 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz