Delphi 为什么选择DevExpress TCxGrid AViewInfo.EditViewInfo.Paint(ACanvas);忽略指定的字体颜色?
我想格式化DevExpressDelphi 为什么选择DevExpress TCxGrid AViewInfo.EditViewInfo.Paint(ACanvas);忽略指定的字体颜色?,delphi,devexpress,Delphi,Devexpress,我想格式化DevExpressTcxGrid(DBTableView),使选定的特殊单元格包含蓝色文本,顶部边框为红色。我已得出以下代码: procedure TTestFrame.ClipsGridCClipsViewCustomDrawCell( Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean); var Tm
TcxGrid(DBTableView)
,使选定的特殊单元格包含蓝色文本,顶部边框为红色。我已得出以下代码:
procedure TTestFrame.ClipsGridCClipsViewCustomDrawCell(
Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
var TmpBounds: TRect;
begin
if IsSpecialCell(...) then begin
ACanvas.Font.Color:=clBlue;
AViewInfo.EditViewInfo.Paint(ACanvas);
TmpBounds:=AViewInfo.Bounds;
TmpBounds.Bottom:=TmpBounds.Top+2;
ACanvas.FillRect(TmpBounds, clRed);
ADone:=True;
end;
end;
不幸的是,此代码忽略了蓝色字体颜色,并以默认格式绘制单元格,只添加红色顶部边框。如果AViewInfo.EditViewInfo.Paint(ACanvas),我想我的问题会得到解决代码>已考虑指定的颜色。不幸的是,此过程使用默认格式
那么,如何解决我的问题呢?通常,是否可以在OnCustomDraw
中绘制某些内容(例如,使用FillRec
绘制单元格的内边框),并在默认绘制过程中绘制一些其他内容(例如,单元格的常用内容)?目前,在我看来,我必须做出选择——是在OnCustomDrawCell
中绘制所有内容,还是让Grid绘制所有内容,我只能在OnCustomDrawCell
中对一些绘图参数(字体颜色、笔刷颜色)进行小配置,以访问私有函数
TcxPainterAccess = class(TcxGridTableDataCellPainter);
procedure TTestFrame.ClipsGridCClipsViewCustomDrawCell(
Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
var APainter : TcxPainterAccess ;
begin
APainter := TcxPainterAccess(TcxViewInfoAcess(AViewInfo).GetPainterClass.Create(ACanvas, AViewInfo));
try
with Apainter do
DrawContent;
DrawBorders;
your code....
finally
Adone := True;
Free;
end;
end;
Devex技术支持对此有何评论?请尝试AViewInfo.Params.TextColor:=clBlue
,这对您有用吗?不幸的是,TextColor的分配没有任何作用。也许是另一个问题给了您灵感?