Autor Beitrag
ruhrpott-desire
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 23



BeitragVerfasst: Sa 19.01.08 20:54 
Hallo,
Also dann hier die Frage ^^
Wie füge ich einem Listview eine neue Zeile hinzu?

Mein Ansatz sieht so aus...

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TAlleLoks.LokAdd2Click(Sender: TObject);
begin
ListView1.Items.Item[0].SubItems.Add ('Hallo');
ListView1.Items.Item[0].SubItems[1]:= 'Hallo';
end;


Aber es klappt leider nicht, da kommt immer eine Fehlermeldung...

Gruß
ruhrpott-desire
Calculon
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 676

Win XP Professional
Delphi 7 PE, Delphi 3 PRO
BeitragVerfasst: So 20.01.08 02:22 
z.B. so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TAlleLoks.LokAdd2Click(Sender: TObject); 
var
  item: Tlistitem;
begin 
  item := ListView1.Items.Add;
  item.Caption := 'Grüzi mitternand';   
end;

_________________
Hallo Mutti
ruhrpott-desire Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 23



BeitragVerfasst: So 20.01.08 17:10 
Danke!!
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: So 20.01.08 20:49 
Auch wenn dein Problem jetzt gelöst ist: Wäre es nicht sinnvoller, eine ListBox zu nehmen? Es sei denn, du willst noch Icons und weitere Spalten benutzen.

In einer ListBox kannst du ganz einfach eine Zeile hinzufügen:

ausblenden Delphi-Quelltext
1:
ListBox1.Items.Add('Hello World!');