Reputation: 3699
I would like to apply a style to a column (on get content style) so all numbers in that column color to the selected style. Just the numbers, nothing else.That means that if a number is found within a text phrase it will get colored. Is this possible ?
Upvotes: 0
Views: 2004
Reputation: 4166
This is rough code but ought to get you in the right direction. I think it may overlap your drawing a little on the canvas but you can adjust where needed. You will also need to adjust so that it parses out the numbers from the strings.
procedure TForm7.cxGrid1TableView1CustomDrawCell(Sender: TcxCustomGridTableView;
ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo;
var ADone: Boolean);
var Bounds : TRect;
begin
Bounds := AViewInfo.Bounds;
ACanvas.Font.Color := clRed;
ACanvas.TextOut(Bounds.Left, Bounds.Top, '123');
Bounds.Left := ACanvas.Canvas.TextWidth('123');
ACanvas.Font.Color := clGreen;
ACanvas.TextOut(Bounds.Left, Bounds.Top, 'abc');
ADone := True;
end;
Upvotes: 0
Reputation: 14001
Sure. Use something like
procedure TForm1.Column1StylesGetContentStyle(
Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
AItem: TcxCustomGridTableItem; var AStyle: TcxStyle);
var
i: Integer;
begin
if TryStrToInt(ARecord.Values[Column1.Index], i) then
AStyle := cxStyle1;
end;
Upvotes: 2