【发布时间】:2017-01-17 11:28:00
【问题描述】:
如何根据特定列中的某个值绘制整行? 我有四列的 TStringGrid:
ID | NAME | DATE | STATE
1 X 2017-01-01 TRUE --whole row need to be yellow
2 Y 2017-01-01 FALSE --default color (no change)
如果我的列 state 的值 true 将整行重绘为黄色。
我已经尝试过了,但它只适用于 state 列:
procedure TTNarudzbenice.grSomeNameDrawColumnCell(Sender: TObject; const Canvas: TCanvas; const Column: TColumn; const Bounds: TRectF;const Row:Integer; const Value: TValue; const State: TGridDrawStates);
var
aRowColor: TBrush;
begin
aRowColor := Tbrush.Create(TBrushKind.Solid,TAlphaColors.Alpha);
//-----
if Value.ToString = 'TRUE' then
begin
aRowColor.Color := TAlphaColors.Yellow;
Canvas.FillRect(Bounds, 0, 0, [], 1, aRowColor);
Column.DefaultDrawCell(Canvas, Bounds, Row, Value, State);
end;
aRowColor.free;
end;
【问题讨论】:
标签: delphi firemonkey tstringgrid