使用DevExpress PivotGrid OnCustomDrawCell事件可以实现点击某一单元格的时候,使其整行和整列突出显示。
效果如下图:
具体实现代码如下:
var
x, y: Integer;
StatDayItem: TcxPivotGridGroupItem;
StatDay: TDateTime;
begin
x := cxDBPivotGrid.ViewData.FocusedCell.X;//当前选中单元格所在列
y := cxDBPivotGrid.ViewData.FocusedCell.Y;//当前选中单元格所在行
if (x = -1) or (y = -1) then Exit;
if (AViewInfo.RowIndex = y) and (AViewInfo.ColumnIndex = x) then Exit;
if (AViewInfo.RowIndex = y) or (AViewInfo.ColumnIndex = x) then
ACanvas.Brush.Color := $00FAECE0;//行列描画颜色
//如果日期=今日
StatDayItem := cxDBPivotGrid.ViewData.Rows[AViewInfo.RowIndex].GetGroupItemByField(fStatDay);
if Assigned(StatDayItem) then
if TryStrToDateTime(StatDayItem.DisplayText, StatDay) then
if StatDay = StartOfTheDay(Now) then
ACanvas.Brush.Color := clMoneyGreen;
end;