Autor Beitrag
florian
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 30

Win XP Home
D5 Enterprise
BeitragVerfasst: So 15.08.04 12:27 
hallo,

ich habe folgendes Problem:
Ich möchte in eine ListView ein neues Item hinzufügen, das mache ich mit diesem
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TForm4.SpeedButton2Click(Sender: TObject);
var new: TListItem;
begin
new := Form2.listView1.Items.Add;
with new do
 begin
  caption := Form4.name.text;
  SubItems[0] := Form4.host.Text;
  SubItems[1] := Form4.user.Text;
  SubItems[2] := Form4.pass.Text;
 end;
 Form4.Close;
end;


Dabei bekomme ich diesen Fehler:
Zitat:
Der Index der Liste überschreitet das Maximum (0)


Wie kann ich den beheben? Suche in Google und Delphi brachte mir bisher nicht den gewünschten Erfolg. :(

Vielen Dank im Voraus!

_________________
"640Kb should be enough for anybody." Bill Gates (in den 80'ern)
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: So 15.08.04 12:30 
// Aaargh! Auf Edit geklickt statt auf Antwort erstellen... :? :autsch: \\

Die Subitems musst Du erst noch adden! Probiers mal damit:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TForm4.SpeedButton2Click(Sender: TObject);
var new: TListItem;
begin
new := Form2.listView1.Items.Add;
with new do
 begin
  caption := Form4.name.text;
  SubItems.Add(Form4.host.Text);
  SubItems.Add(Form4.user.Text);
  SubItems.Add(Form4.pass.Text);
 end;
 Form4.Close;
end;


raziel

_________________
JSXGraph


Zuletzt bearbeitet von raziel am So 15.08.04 12:36, insgesamt 3-mal bearbeitet
florian Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 30

Win XP Home
D5 Enterprise
BeitragVerfasst: So 15.08.04 12:31 
Danke schön!
Funktionniert prima!
:D

_________________
"640Kb should be enough for anybody." Bill Gates (in den 80'ern)
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: So 15.08.04 12:36 
Was mit grad noch einfällt: Du brauchst new eigentlich gar nicht:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm4.SpeedButton2Click(Sender: TObject);
begin
with Form2.listView1.Items.Add do
 begin
  caption := Form4.name.text;
  SubItems.Add(Form4.host.Text);
  {...}

So, jetz dürfts passn.

raziel

_________________
JSXGraph
florian Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 30

Win XP Home
D5 Enterprise
BeitragVerfasst: So 15.08.04 14:55 
aso.. ja stimmt :)

_________________
"640Kb should be enough for anybody." Bill Gates (in den 80'ern)