我正在尝试更改Delphi XE6中DBGRID组件的特定列的标题单元格的颜色。当网格按某一列排序时,我经常绘制列标题。
DBGRID1.Columns[1].Title.Color := clBlue;这个是可能的吗?或者有没有更好的方法来突出显示已排序的列?
发布于 2014-07-30 23:00:47
尝试覆盖procedure 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中工作。
发布于 2022-02-09 09:36:36
好吧,如果我理解您的问题,您所需要做的就是将DBGrid DrawingStyle属性更改为gdsGradient,然后将gradentEndColor和gradentStartColor更改为相同的颜色。
https://stackoverflow.com/questions/23786855
复制相似问题