Files
lazarus-ccr/components/nicegrid/demos/Owner Draw/common/main.pas
wp_xxyyzz 9884b87d80 NiceGrid: Initial commit
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8841 8e941d3f-bd1b-0410-a28a-d453659cc2b4
2023-06-23 15:21:39 +00:00

63 lines
1.2 KiB
ObjectPascal

unit Main;
{$IFDEF FPC}
{$MODE Delphi}
{$ENDIF}
interface
uses
SysUtils, Variants, Classes, Types, Graphics, Controls, Forms,
Dialogs, ExtCtrls, NiceGrid;
type
TMainForm = class(TForm)
NiceGrid1: TNiceGrid;
procedure FormCreate(Sender: TObject);
procedure NiceGrid1DrawCell(Sender: TObject; ACanvas: TCanvas;
X, Y: Integer; Rc: TRect; var Handled: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
MainForm: TMainForm;
implementation
{$IFDEF FPC}
{$R *.lfm}
{$ELSE}
{$R *.dfm}
{$ENDIF}
procedure TMainForm.FormCreate(Sender: TObject);
var
x: Integer;
begin
for x := 0 to 19 do
begin
NiceGrid1.Cells[0, x] := IntToStr(Random(100));
NiceGrid1.Cells[1, x] := IntToStr(Random(100));
NiceGrid1.Cells[2, x] := IntToStr(Random(100));
NiceGrid1.Cells[3, x] := IntToStr(Random(100));
NiceGrid1.Cells[4, x] := IntToStr(Random(100));
end;
end;
procedure TMainForm.NiceGrid1DrawCell(Sender: TObject; ACanvas: TCanvas; X,
Y: Integer; Rc: TRect; var Handled: Boolean);
var
i: Integer;
begin
i := StrToIntDef(NiceGrid1.Cells[X, Y], 0);
if Odd(i)
then ACanvas.Font.Color := clRed;
if ((i mod 10) = 0)
then ACanvas.Brush.Color := clYellow;
end;
end.