delphi cxgrid 自定義畫焦點框

Tag發表於2024-05-19
procedure TMyTable.MyBandedTableViewCustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);  
var  
  bounds: TRect;  
begin  

  if AViewInfo.Focused then  
  begin  
    bounds:= AViewInfo.Bounds;  
    Dec(bounds.Right, 1);  
    Dec(bounds.Bottom,1);  
    ACanvas.DrawComplexFrame(bounds, clBlack, clBlack, cxBordersAll, 2);  
    aDone := True;  
  end;  

  //刪除選中背景顏色,一般可以透過設定去掉.不用也行
  if AViewInfo.Selected then  
  begin  
    if Odd(AViewInfo.GridRecord.RecordIndex) then  
      ACanvas.FillRect(AViewInfo.Bounds, RootLookAndFeel.Painter.DefaultContentOddColor )  
    else  
      ACanvas.FillRect(AViewInfo.Bounds, RootLookAndFeel.Painter.DefaultContentEvenColor );  
    ACanvas.Font.Color := RootLookAndFeel.Painter.DefaultContentTextColor ;  
  end;  

end;

相關文章