Czesc
Jak zrobic by na gridzie co drugi wiersz był innego koloru?
Czesc
Jak zrobic by na gridzie co drugi wiersz był innego koloru?
Jak zrobić tego typu rzeczy opisałem w tym poście [Delphi] ListBox - co drugie tło Itema jasnoszare
niestety nie jestem w stanie wyłuskac zmiany wiersza
http://ge0dezja.prv.pl/kolorki.jpg
a zrobiłem to tak:
OnDrawColumnCell
...
If not (gdSelected in State) then
Begin
If (q.RecNo mod 2) = 0 then
(Sender as TDBGrid).Canvas.Brush.Color := K_KNP_WYGLAD_COLOR_GRID1
else
(Sender as TDBGrid).Canvas.Brush.Color := K_KNP_WYGLAD_COLOR_GRID2;
End;
...
K_KNP_WYGLAD_COLOR_GRID , K_KNP_WYGLAD_COLOR_GRID1, K_KNP_WYGLAD_COLOR_GRID2 : TColor;
...
RozbijKolory(K_KNP_WYGLAD_COLOR_GRID,K_KNP_WYGLAD_COLOR_GRID1, K_KNP_WYGLAD_COLOR_GRID2);
...
procedure RozbijKolory(aCol : TColor; var aCol1, aCol2 : TColor);
var R, G, B : Integer;
Begin
R := GetRValue(Abs(aCol));
G := GetGValue(Abs(aCol));
B := GetBValue(Abs(aCol));
aCol1 := RGB(Min(255, R + 8), Min(255, G + 8), Min(255, B + 8));
aCol2 := RGB(Max(0, R - 8), Max(0, G - 8), Max(0, B - 8));
End;
...
Należy się flaszka.
b
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var c:TColor;
begin
if (ARow mod 2)=0 then c:=clWhite else c:=clSkyBlue;
with (Sender as TStringGrid).Canvas do
begin
Brush.Color:=c;
FillRect(Rect);
TextOut(Rect.Left,Rect.Top,(Sender as TStringGrid).Cells[ACol,ARow]);
end;
end;