Autor Beitrag
delphimike
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 117



BeitragVerfasst: Mi 19.01.05 15:29 
Wie kann ich jede 2. Zeile in einem TListview (Modus report) anders einfärben.
Zebrastreifenlook zur besseren Lesbarkeit
Spaceguide
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 552


(D3/D7/D8) Prof.
BeitragVerfasst: Mi 19.01.05 17:08 
Als erstes fällt mir ein: OnDrawItem mit eigener Routine überschreiben.
toms
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1099
Erhaltene Danke: 2



BeitragVerfasst: Mi 19.01.05 17:17 
Spaceguide hat folgendes geschrieben:
Als erstes fällt mir ein: OnDrawItem mit eigener Routine überschreiben.


Ein Beispiel findest du hier:
www.swissdelphicente.../showcode.php?id=818
matze.de
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 576

Win95, Win98 SE, WinXp Prof SP2
D7P, D8P, FPC2.0
BeitragVerfasst: Mi 19.01.05 18:13 
versuch mal das hier :)

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
procedure TForm1.DrawListBoxZC(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
const
  Col1: array[Boolean] of TColor = ($00C7C7C7$00C7C7C7); //Farbe für Col1
  Col2: array[Boolean] of TColor = (clBlack, clBlack);  //Farbe für Col2
var
  TopDif: Integer;
begin
  with (Control as TListBox) do
  begin
    if odSelected in State then
    begin
      Canvas.Brush.Style := bsClear;
      Canvas.Font.Color := clCaptionText;
    end
    else
    begin
      Canvas.Brush.Color := Col1[Odd(Index)];
      Canvas.Font.Color := Col2[(Control as TListBox).Enabled];
    end;
    TopDif := (ItemHeight div 2) - (Canvas.TextHeight(#32div 2);
    Canvas.TextRect(Rect, Rect.Left, Rect.Top + TopDif, Items[Index]);
  end;
end;


aufruf geht so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.ApplicationListDrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
begin
  DrawListBoxZC(Control, Index, Rect, State);
end;


mfg matze

_________________
si tacuisses, philosophus mansisses.