Einzelnen Beitrag anzeigen

marabu

Registriert seit: 6. Apr 2005
10.109 Beiträge
 
#18

Re: Listenindex überschreitet das Maximum

  Alt 15. Dez 2006, 16:01
Hallo,

oder du stellst deinen Code noch etwas mehr um:

Delphi-Quellcode:
function AddString(vle: TValueListEditor; li: TListItem;
    const name: String; index: Integer): Integer;
var
  value: String;
begin
  if index < 0 then
    Result := vle.InsertRow(name, li.Caption, True) else
  begin
    if index < li.SubItems.Count
      then value := li.SubItems[index]
      else value := '';
    Result := vle.InsertRow(name, value, True);
  end;
end;

procedure TForm1.ListView1Click(Sender: TObject);
begin
  with ListView1 do
    if Assigned(Selected) then
    begin
      vle1.Strings.Clear;
      vle1.Strings.BeginUpdate;
      vle1.TopRow := AddString(vle1, Selected, 'Config-Name', -1);
      AddString(vle1, Selected, 'Datasource-Name', 0);
      AddString(vle1, Selected, 'Service-URL', 1);
      AddString(vle1, Selected, 'LFS-Cache-Path', 2);
      AddString(vle1, Selected, 'LFS-Config-Name', 3);
      vle1.Strings.EndUpdate;

      vle2.Strings.Clear;
      vle2.Strings.BeginUpdate;
      vle2.TopRow := AddString(vle2, Selected, 'Datasource-Name', 4);
      AddString(vle2, Selected, 'Database-Type', 5);
      AddString(vle2, Selected, 'Database-URL', 6);
      AddString(vle2, Selected, 'Database-Driver', 7);
      AddString(vle2, Selected, 'LFS-Config-Name', 8);
      AddString(vle2, Selected, 'LFS-Cache-Path', 9);
      AddString(vle2, Selected, 'DB-User', 10);
      AddString(vle2, Selected, 'DB-Password', 11);
      AddString(vle2, Selected, 'LFS-User', 12);
      AddString(vle2, Selected, 'LFS-Password', 13);

      if vle2.Strings.Values['Datasource-Name'] = 'then
        ShowMessage('The Configuration ' + listview1.Selected.Caption + ' is corrupt!');

      vle2.Strings.EndUpdate;
    end;
end;
Getippt und nicht getestet.

Freundliche Grüße
  Mit Zitat antworten Zitat