繁体   English   中英

DBGRID 列标题颜色

[英]DBGRID Columns Title Color

我正在尝试更改 Delphi XE6 中 DBGRID 组件特定列中标题单元格的颜色。 当网格按特定列排序时,我曾经绘制列标题。

DBGRID1.Columns[1].Title.Color := clBlue;

这可能吗? 或者有没有更好的方法来突出显示排序列?

尝试覆盖过程TCustomDBGrid.DrawCellBackground强制标题的背景色:

procedure TMyDBGrid.DrawCellBackground(const ARect: TRect; AColor: TColor; AState: TGridDrawState; ACol, ARow: integer);
begin
  if (FLastSortedColumnIdx = ACol) and (ACol >= 0) and (ARow = -1) then
    AColor := Columns[ACol].Title.Color;

  inherited;
end;

FLastSortedColumnIdx是您存储已排序列的Column.Index的字段。

应该可以在Delphi XE3中使用。

好吧,如果我理解你的问题,你需要做的就是将 DBGrid DrawingStyle属性更改为gdsGradient ,然后将gradentEndColorgradentStartColor更改为相同的颜色。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM