Reputation: 863
I used default style "Amethyst Kamri" in application. And my DBgrid's selected row color change according to style. 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
Now i want to change color. How to do this?
Upvotes: 0
Views: 2845
Reputation: 1022
You need first to inherit the TDBGrid from the Vcl.DBGrids.TDBGrid calss .And override the Paint procedure . 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 :
Upvotes: 1