我正在尝试更改Delphi XE6中DBGRID组件中特定列的标题单元格的颜色。以前当网格按该特定列排序时,我会绘制列标题。
DBGRID1.Columns[1].Title.Color := clBlue;
这是可能的吗?或者有更好的方法来突出显示排序列吗?
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
,然后将gradentEndColor
和gradentStartColor
更改为相同的颜色。
DBGrid1.Columns[1].Title.Font.Color := clBlue;
吗? - undefined