2014-02-08 38 views

回答

1

您需要首先從Vcl.DBGrids.TDBGrid calss繼承TDBGrid。並覆蓋Paint程序。 像這樣:

type 
    TDBGrid = class(Vcl.DBGrids.TDBGrid) 
    protected 
    procedure Paint; override; 
    end; 

上油漆過程:

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; 

這是最終的結果:

enter image description here

+0

我需要改變** slected行**的BackGround顏色也。 – Ganesh

相關問題