Autor Beitrag
dragon77
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 39



BeitragVerfasst: Mi 14.12.05 23:51 
Hallo, ich nutze ein DVAdvListView von TMS. Ich glaube es wurde von der CustomListView abgeleitet. Wie auch immer jedenfalls habe ich ein komisches Problem:

Mein Programm hat 2 Forms.
Wenn ich auf der ersten Form (dort ist aus das DBAdvListView) ein Label (label3) haben und diesen code ausführe:
ausblenden Delphi-Quelltext
1:
label3.Caption := DBAdvListView1.ItemFocused.Caption;					

Dann klappt das ohne Probleme. Ich bekomme die gewünschte Ausgabe.

Aber wenn ich auf der Form2 diesen Code hier hinschreibe:
ausblenden Delphi-Quelltext
1:
lblFirma1.Caption := form1.DBAdvListView1.ItemFocused.Caption;					

dann bekomme ich eine AccsesViolation.
In der uses Klausel steht die erste Form drin. Wieso klappt der quasi selbe code in diesem Fall nicht?
Stefan.Buchholtz
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 612

WIN 2000, WIN XP, Mac OS X
D7 Enterprise, XCode, Eclipse, Ruby On Rails
BeitragVerfasst: Do 15.12.05 09:07 
Ich kenne die entsprechende Komponente nicht, aber kann es sein, dass ItemFocused nil ist, wenn das ListView nicht den Eingabefocus hat?
Probier in deinem 2. Form mal folgendes:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
if Assigned(form1.DBAdvListView1.ItemFocused) then
  lblFirma1.Caption := form1.DBAdvListView1.ItemFocused.Caption
else
  ShowMessage('DBAdvListView1.ItemFocused = nil');


Wenn die Messagebox kommt, musst du es anders machen. Du könntest zum Beispiel die Caption in ein Property von Form1 schreiben und von Form2 darauf zugreifen.

Stefan

_________________
Ein Computer ohne Windows ist wie eine Schokoladentorte ohne Senf.
Wollaston
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 27



BeitragVerfasst: Do 15.12.05 12:40 
Hallo,

probiere einfach für Deine Form2-Listview anstatt ItemFocused mal Listview.Selected aus und mach vorher eine Abfrage ob das entsprechende Item Nil ist.


mfg Wollaston