我想将样式应用于列(获取内容样式),以便该列颜色中的所有数字都适用于所选样式。只有数字,没有别的。这意味着如果在文本短语中找到一个数字,它将被着色。这可能吗 ?
问问题
1426 次
2 回答
2
当然。使用类似的东西
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;
于 2014-05-24T05:33:53.073 回答
0
这是粗略的代码,但应该让您朝着正确的方向前进。我认为它可能会在画布上与您的绘图重叠一点,但您可以在需要的地方进行调整。您还需要进行调整,以便它从字符串中解析出数字。
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;
于 2014-05-28T03:32:12.297 回答