cxGrid单元格内显示图片和文本

来源:互联网 发布:淘宝店铺自定义模块 编辑:程序博客网 时间:2024/05/17 07:03

cxGrid单元格内显示图片和文本,下图是根据单据的状态来绘制图:











绘制代码为通用代码:

procedure cxGridViewCustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;      AViewInfo: TcxGridTableDataCellViewInfo;  var ADone: Boolean);var  x,y:Integer;  ABitmap:TBitmap;begin  {省略初始化ABitmap的代码略}  //调整图片的位置  if (AViewInfo.Bounds.Right- AViewInfo.Bounds.Left - ABitmap.Width)>0 then    x := AViewInfo.Bounds.Right- ABitmap.Width-1 else    x := AViewInfo.Bounds.Left;  if (AViewInfo.Bounds.Bottom- AViewInfo.Bounds.Top - ABitmap.Height)>0 then    y := AViewInfo.Bounds.Bottom- ABitmap.Height-1 else    y := AViewInfo.Bounds.Top;  ACanvas.FillRect(AViewInfo.Bounds);  ACanvas.Draw(x,y,ABitmap);  ACanvas.Brush.Style := bsClear;  ACanvas.DrawTexT(AViewInfo.Text, AViewInfo.ContentBounds, cxAlignVCenter);  ADone := True;end;


0 0
原创粉丝点击