cxgrdbclmnGrid1DBTableView1IconImage的Properties设置为Image
procedure TForm1.tvGrid1DBTableView1CustomDrawCell(
Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
var
AEditValue: Variant;
APicture: TPicture;
FBounds:TRect;
begin
cxgrdbclmnGrid1DBTableView1IconImage.Options.Focusing:=False; //点上去图标不变
if AViewInfo.Item <> cxgrdbclmnGrid1DBTableView1IconImage then
begin
Exit;
end;
AEditValue := AViewInfo.GridRecord.Values[cxgrdbclmnGrid1DBTableView1IconImage.Index];
if VarIsStr(AEditValue) or VarIsArray(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;