grid w 2 kolorach

0

Czesc

Jak zrobic by na gridzie co drugi wiersz był innego koloru?

0

Jak zrobić tego typu rzeczy opisałem w tym poście [Delphi] ListBox - co drugie tło Itema jasnoszare

0

niestety nie jestem w stanie wyłuskac zmiany wiersza

0

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

0
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;

1 użytkowników online, w tym zalogowanych: 0, gości: 1