unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, JvExGrids, JvStringGrid;
type
TForm1 = class(TForm)
JvSGFlux: TJvStringGrid;
procedure FormCreate(Sender: TObject);
procedure JvSGFluxDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
JvSGFlux.Cells[3, 3] := '1';
end;
procedure TForm1.JvSGFluxDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
with TJvStringGrid(sender) do
begin
for ACol := 0 to Colcount - 1 do
for ARow := 0 to RowCount - 1 do
if Cells[ACol, ARow] = '1' then
begin
canvas.Brush.Color := ClRed;
canvas.FillRect(Rect);
end;
end;
end;
end.
procedure TForm1.SGSampleDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
for i := 1 to 100 do
With SGSample As TStringGrid Do
With Canvas Do
Begin
if ((Cells[4,i]='POS') AND (Cells[2,i]='NEG')) OR ((Cells[4,i]='NEG') AND (Cells[2,i]='POS')) then
begin
cells[5,i]:='1';
Rect := CellRect(4, i);
Brush.Color := clRed;
Font.Color := clBlack;
FillRect(Rect);
DrawText(Canvas.Handle, PChar(Cells[4,i]), -1, Rect ,
DT_CENTER or DT_NOPREFIX or DT_VCENTER or DT_SINGLELINE );
Rect := CellRect(2, i);
Brush.Color := clRed;
Font.Color := clBlack;
FillRect(Rect);
DrawText(Canvas.Handle, PChar(Cells[2,i]), -1, Rect ,
DT_CENTER or DT_NOPREFIX or DT_VCENTER or DT_SINGLELINE );
end;
end;
end;
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question