Einzelnen Beitrag anzeigen

fl63

Registriert seit: 30. Mär 2008
124 Beiträge
 
#8

Re: nochmals StringGridDrawcell

  Alt 26. Aug 2009, 16:41
Ich habe DrawCell aus der Rechenroutine gestrichen und es passiert nichts.

Im übrigen ist das der komplette Code

Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Grids, JvExGrids, JvStringGrid;

type
  TForm1 = class(TForm)
    JvSG1: TJvStringGrid;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    Procedure Rechnen(Sender: TObject);
    procedure DrawCell(Sender: TObject; Col, Row: Integer; Rect: TRect; State: TGridDrawState);


  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}


procedure TForm1.Button1Click(Sender: TObject);
begin
//Lade Datei
JvSG1.LoadFromCSV('messwerte.txt',#9);
//Färbe Spalte 2
Rechnen(Sender);
//Spring zur letzten Zeile
//JvSG1.Row := JvSG1.RowCount-1;

end;

Procedure TForm1.Rechnen(Sender: TObject);
var i:Integer;
   k,l:extended;

begin
  For i := 2 to JvSG1.RowCount-1 do
    k := StrToFloat(JvSG1.Cells[2,i]); l := StrToFloat(JvSG1.Cells[2,i-1]);
    If k > l then
    begin
    JvSG1.Canvas.Brush.Color := clred;
// DrawCell(Sender,2,i,Rect(0,0,0,0),[gdselected]) ;
    end;
end;

procedure TForm1.DrawCell(Sender: TObject; Col, Row: Integer;
  Rect: TRect; State: TGridDrawState);
begin
  (sender as TStringgrid).canvas.Brush.color:=(sender as TStringgrid).color;
  (sender as TStringgrid).canvas.Font.color:=clWindowText;
  if (col<(sender as TStringgrid).fixedCols) or (row<(sender as TStringgrid).fixedRows) then
    (sender as TStringgrid).canvas.Brush.color:=(sender as TStringgrid).FixedColor //farbe der Header
  else if gdSelected in state then
  begin
    (sender as TStringgrid).canvas.Brush.color:=clHighlight; //farbe von markierung
    (sender as TStringgrid).canvas.Font.color:=clWindow;
  end else if integer(JVSG1.objects[col,row])=2 then
    (sender as TStringgrid).canvas.Brush.color:=clgreen;
  (sender as TStringgrid).canvas.FillRect(rect);
  (sender as TStringgrid).canvas.TextOut(rect.left+2,rect.top+2,(sender as TStringgrid).Cells[col,row]);
end;


end.
  Mit Zitat antworten Zitat