Autor Beitrag
rmasterb
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 71



BeitragVerfasst: Mo 12.05.03 12:13 
ich wollte lediglich eine beliebige zeile einer listview einfärben und bekomme es einfach nicht hin. ich erbitte hilfe und wenn es möglich ist einen knappen code. danke

Moderiert von user profile iconTino: Titel geändert.
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Di 13.05.03 16:09 
geht über die Customdraw*-ereignisse.

ausblenden Quelltext
1:
2:
3:
4:
5:
procedure TForm1.ListView1CustomDrawItem(Sender: TCustomListView;
  Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
begin
  if odd(item.Index) then TListview(Sender).Canvas.brush.Color := clblue
end;

macht dir jede zweite Zeile blau

ein weitere Beispiel findest du im Demo ordner unter virtuallistview

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
rmasterb Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 71



BeitragVerfasst: Di 13.05.03 20:34 
Titel: hmm?
danke für die antwort :-)
jetzt gibt es nur noch ein kleins problmchen. ich hab die listviews dynamisch erstellt und hab ein problem die procedur für die oncustomdrawitem zu erstellen
ausblenden Quelltext
1:
procedure farbzeile(Sender: TCustomListView;Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);					

beim versuch zum compilieren zeigt der immer ein
Zitat:

[Fehler] Unit1.pas(34): Ungenügende Forward- oder External-Deklaration: 'TForm1.farbzeile'

wenn man mir jetzt noch sagt wie ich das problem löse ist so gut wie alle geschafft
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Di 13.05.03 20:41 
mach mal folgendes

ausblenden Quelltext
1:
2:
3:
4:
5:
procedure TForm1.ListViewCustomDrawItem(Sender: TCustomListView;
  Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
begin
  if odd(item.Index) then TListview(Sender).Canvas.brush.Color := clblue
end;

(in ListviewCustomdrawitem umbenannt)
die Deklaration fügst du noch zum PrivateTeil der Form hinzu.
durch das TListview(Sender) ist es egal, von welchem Listview die Proc aufgerufen wird. Es muß nur ein Listview sein, sonst schepperts.

beim erstellen deiner Listviews gibst du dann an:
ausblenden Quelltext
1:
2:
3:
4:
meinErstelltesListview:=TListview.create....
....
meinErstelltesListview.oncustomdrawitem:=ListViewCustomDrawItem;
....


Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
rmasterb Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 71



BeitragVerfasst: Mi 14.05.03 08:33 
ok ich hab es so deklarariert:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
tform = class(tform)
.
.
.
private
 procedure farbzeile(Sender: TCustomListView;Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);

jetzt habe ich im hauptteil der oncustomdrawitem die procedure farbzeile zugewiesen.ich habe auch eine farbzeile procedure geschrieben und jetzt das problem:
wenn ich in die procedure mehr als Sender: TCustomListView bringt er den Fehler
Zitat:

[Fehler] Unit1.pas(34): Ungenügende Forward- oder External-Deklaration: 'TForm1.farbzeile'

schreibe ich nur Sender: TCustomListView sagt er, dass es die proceduren nicht kompartiebel sind oder so.
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Mi 14.05.03 09:44 
du muß im implemention teil aber auch schreiben
ausblenden Quelltext
1:
procedure Tform1.Farbzeile(Sender....);					


ansonsten poste es mal komplett (Form-Deklaration und deine Proc Farbzeile)

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
rmasterb Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 71



BeitragVerfasst: Mi 14.05.03 13:32 
ok
SCHANDE ÜBER MEIN HAUPT :oops: