Autor Beitrag
rob87
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 461

Win Me, Win XP Home, Win XP Prof
Delphi 2007 Enterprise
BeitragVerfasst: Mi 05.09.07 11:42 
Ich habe zwei veschachtelte for-Schleifen, welche mir den Inahlt eines TMenu in ein StringGrid schreiben.

Soweit, sogut. Nun hat meine zweite Spalte des Menüs nicht soviele Unterpunkte wie die Erste.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
  for x := 0 to statistikmenue.MainMenu1.Items.Count -1 do begin  //Horizontale Schleife

    for y := 0 to Statistikmenue.MainMenu1.Items.Count -1 do begin  //Vertikale S.

        StringGrid1.Cells[x+1,y+1] := Statistikmenue.MainMenu1.Items[x][y].Caption;

    end;
  end;

Deswegen bekomme ich, sobald er beim letzten Wert in der Spalte angekommen ist, folgende Fehlermeldung:

ListenIndex überschreitet das Maximum.

Hat jemand ne Idee, wie ich des abfangen könnte. If-Abfrage? Wenn kein Wert enthalten, gehe zur nächsten Spalte.
Aber wie kann ich sowas abfragen??
Martin1966
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1068

Win 2000, Win XP
Delphi 7, Delphi 2005
BeitragVerfasst: Mi 05.09.07 12:18 
eventuell so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
  for x := 0 to statistikmenue.MainMenu1.Items.Count -1 do begin  //Horizontale Schleife
    for y := 0 to Statistikmenue.MainMenu1.Items[x].Count -1 do begin  //Vertikale S.
        StringGrid1.Cells[x+1,y+1] := Statistikmenue.MainMenu1.Items[x][y].Caption;
    end;
  end;

_________________
Ein Nutzer der Ecke ;-)
rob87 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 461

Win Me, Win XP Home, Win XP Prof
Delphi 2007 Enterprise
BeitragVerfasst: Mi 05.09.07 13:38 
Jo. Passt. Vielen Dank.