procedureTForm1.tvGrid1DBTableView1CustomDrawCell(
Sender:TcxCustomGridTableView;ACanvas:TcxCanvas;
AViewInfo:TcxGridTableDataCellViewInfo;varADone:Boolean);
var
AEditValue:Variant;
APicture:TPicture;
FBounds:TRect;
begin
cxgrdbclmnGrid1DBTableView1IconImage.Options.Focusing:=False;//点上去图标不变
ifAViewInfo.ItemcxgrdbclmnGrid1DBTableView1IconImagethen
begin
Exit;
end;
AEditValue:=AViewInfo.GridRecord.Values[cxgrdbclmnGrid1DBTableView1IconImage.Index];
ifVarIsStr(AEditValue)orVarIsArray(AEditValue)then
begin
APicture:=TPicture.Create;
try
LoadPicture(APicture,
TcxImageProperties(cxgrdbclmnGrid1DBTableView1IconImage.Properties).GraphicClass,AEditValue);
APicture.Bitmap.Canvas.Brush.Style:=bsClear;
APicture.Bitmap.Canvas.TextOut(10,40,AViewInfo.GridRecord.Values[cxgrdbclmnGrid1DBTableView1CName.Index]);//文本显示的位置自己根据需要调整把
FBounds:=AViewInfo.Bounds;
ACanvas.FillRect(FBounds);
ACanvas.DrawComplexFrame(FBounds,clBtnHighlight,clBtnShadow,[bBottom,bLeft,bRight],1);
InflateRect(FBounds,-1,-1);
ACanvas.Font.Color:=clBlack;
ACanvas.Brush.Style:=bsClear;
ACanvas.DrawGlyph(FBounds.Left,FBounds.Top,APicture.Bitmap);
finally
APicture.Free;
end;
end;
ADone:=True;
end; |