Delphi XE2 (Pro)
Win 7 (pro)
TAdvStringGrid ver. 8.4.2.3
When I drop a TADVStringGrid on a form, and leave all default values, but set the "OnGetCellColor" handler to following:
procedure TForm1.AdvStringGrid1GetCellColor(Sender: TObject; ARow,
ACol: Integer; AState: TGridDrawState; ABrush: TBrush; AFont: TFont);
begin
if AState * [gdSelected,gdFocused] = [] then
begin
if (ACol=2) and (ARow=2) then
begin
ABrush.Color:=clYellow;
AFont.Color:=clMaroon;
end else
begin
ABrush.Color:=clWhite;
AFont.Color:=clGreen;
end;
end else
begin
if (ACol=2) and (ARow=2) then
begin
ABrush.Color:=clMaroon;
AFont.Color:=clYellow;
end else
begin
ABrush.Color:=clGreen;
AFont.Color:=clWhite;
end;
end;
end;
Also "OnGetDispText" handler:
procedure TForm1.AdvStringGrid1GetDisplText(Sender: TObject; ACol,
ARow: Integer; var Value: string);
begin
if (ACol=2) and (ARow=2) then
begin
Value:='Hello';
end else
begin
if (ACol=3) and (ARow=3) then
Value:='World';
end;
end;
The unselected cells behaves correctly, but if I select the cell, the brush and font just shows the default colors.
How can I control font / brush when the cell is selected in runtime?
Br.
Anders