[英]How to change selected row's border color and background color of style enabled DBGrid in delphi xe2?
I used default style "Amethyst Kamri" in application. 我在应用程序中使用了默认样式“ Amethyst Kamri”。 And my DBgrid's selected row color change according to style.
而且我的DBgrid选择的行颜色根据样式而变化。 But i want to change selected row's border color and background color.
但我想更改所选行的边框颜色和背景颜色。 I change font style using the answer of following question.
我使用以下问题的答案来更改字体样式。
https://stackoverflow.com/a/9472000 https://stackoverflow.com/a/9472000
Now i want to change color. 现在我想改变颜色。 How to do this?
这个怎么做?
You need first to inherit the TDBGrid from the Vcl.DBGrids.TDBGrid calss .And override the Paint procedure . 首先需要从Vcl.DBGrids.TDBGrid calss继承TDBGrid。并重写Paint过程。 Like this :
像这样 :
type
TDBGrid = class(Vcl.DBGrids.TDBGrid)
protected
procedure Paint; override;
end;
On the Paint procedure : 在“涂漆”过程中:
procedure TDBGrid.Paint;
var
i, X, Y: Integer;
begin
inherited;
Y := RowHeights[0] + 1;
X := Width;
for i := 1 to Self.RowCount - 1 do
begin
Y := Y + RowHeights[i] + 1;
Canvas.Brush.Color := clRed;
Canvas.FillRect(Rect(0, Y, X, Y + 1));
end;
end;
And this is the final result : 这是最终结果:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.