Registriert seit: 19. Jul 2017
Ort: Berlin
47 Beiträge
Delphi XE7 Ultimate
|
AW: VirtualStringTree Komponente
10. Nov 2017, 11:20
Eigentlich will ich nur meine normale Rutine so umändern das si stat die normale ListView eben die VirtualStringTree befüllt.
Delphi-Quellcode:
procedure AddList;
var
Data: PTreeData;
XNode: PVirtualNode;
Rand: Integer;
ListItem: TListItem;
p: Integer;
Strings, StringList: TStringList;
CurrentString: string;
EntryString: string;
begin
Strings := TStringList.Create;
StringList := TStringList.Create;
Strings.Clear;
Stringlist.Clear ;
Strings.BeginUpdate;
StringList.BeginUpdate;
Strings.Text := Data2;
form1.ListView1.Items.BeginUpdate;
i := 0;
try
for I := 0 to Strings.Count - 1 do
begin
CurrentString := Strings.Strings[I];
EntryString := Split(CurrentString, '|', 1);
ListItem := form1.ListView1.FindCaption(0, EntryString, False, True, False);
if ListItem = nil then
begin
ListItem := form1.ListView1.Items.Add;
ListItem.Caption := EntryString;
ListItem.SubItems.Add(Split(CurrentString, '|', 2));
ListItem.SubItems.Add(Split(CurrentString, '|', 3));
ListItem.SubItems.Add(Split(CurrentString, '|', 4));
ListItem.SubItems.Add(Split(CurrentString, '|', 5));
ListItem.SubItems.Add(Split(CurrentString, '|', 6));
end else begin
ListItem.StateIndex := 0;
EntryString := Split(CurrentString, '|', 2);
if ListItem.SubItems[0] <> EntryString then
ListItem.SubItems[0] := EntryString;
EntryString := Split(CurrentString, '|', 4);
if ListItem.SubItems[2] <> EntryString then
ListItem.SubItems[2] := EntryString;
end;
StringList.Add(ListItem.Caption);
end;
application.ProcessMessages;
for I := form1.ListView1.Items.Count - 1 downto 0 do
begin
ListItem := form1.ListView1.Items[I];
if ListItem.StateIndex = 2 then
begin
ListItem.Delete;
Continue;
end;
p := StringList.IndexOf(ListItem.Caption);
if p = -1 then
ListItem.StateIndex := 2;
end;
finally
form1.ListView1.Items.EndUpdate;
form1.ListView1.Refresh;
StringList.EndUpdate;
Strings.EndUpdate;
StringList.Free;
Strings.Free;
end;
end;
Pascal
|
|
Zitat
|