Reputation: 2729
In my application, I need co draw some grid columns (not completely rows) in different colors. How can I get current columt id, from TcxGridTableDataCellViewInfo variable?
Thanks.
Upvotes: 4
Views: 10268
Reputation: 2808
Example:
procedure TFrmBestellingen.grdRequestDBTableCustomDrawCell(
Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;AViewInfo:
TcxGridTableDataCellViewInfo; var ADone: Boolean);
var
varValue: Variant;
begin
inherited;
// Which column must i paint: Paint on column <TcxGridDbColumn>
if (AViewInfo.Item.Index = <TcxGridDbColumn>.Index) then
begin
// Get Value to compare if it is 100
varValue:=AViewInfo.GridRecord.Values[<TcxGridDbColumn>.Index];
if (Not VarIsNull(varValue)) and
(varValue=100) then
begin
ACanvas.Font.Style:= [fsBold];
ACanvas.Brush.Color:= clSilver;
end;
end;
end;
Upvotes: 5
Reputation: 14001
You can use AViewInfo.Item.Index.
Alternatively you could assign a different OnCustomDrawCell handler to each column instead of a single one to the view. Then there is no need to differentiate the columns.
Upvotes: 6