Angesichts des doch recht überschaubaren Codes der Komponente stellt sich die Frage, wo genau die Fehler auftauchen.
Gute Frage. Ich hatte mir den Sourcecode gar nicht angeschaut. Das sind ja gerade mal 100 Zeilen und davon sind auch noch 60 Zeilen Kommentare.
Zumindest, wenn man die Komponente zur Laufzeit erzeugt, funktioniert sie:
Leeres Formular plus folgender Code:
Delphi-Quellcode:
unit Unit1;
interface
uses
Winapi.Windows,
Winapi.Messages,
System.SysUtils,
System.Variants,
System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.Grids,
clrgrid;
type
TForm1 =
class(TForm)
private
sg_Main: TColorStringGrid;
procedure HandleOnGetCellColor(Sender: TObject; ARow, ACol: Longint;
AState: TGridDrawState;
ABrush: TBrush; AFont: TFont);
public
constructor Create(_Owner: TComponent);
override;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
constructor TForm1.Create(_Owner: TComponent);
begin
inherited;
sg_Main := TColorStringGrid.Create(Self);
sg_Main.
Name := '
sg_Main';
sg_Main.Parent := Self;
sg_Main.Left := 72;
sg_Main.Top := 64;
sg_Main.Width := 320;
sg_Main.Height := 120;
sg_Main.TabOrder := 0;
sg_Main.OnGetCellColor := HandleOnGetCellColor;
end;
procedure TForm1.HandleOnGetCellColor(Sender: TObject; ARow, ACol: Longint; AState: TGridDrawState;
ABrush: TBrush; AFont: TFont);
begin
if ARow
mod 2 = 0
then
ABrush.Color := clred
else
ABrush.Color := clblue;
end;
end.