I have a TreeView on a form and a button that clears the items and adds new items in
If there are enough items to go off the screen so you have to scroll to view them all, the second time i click the button i’m getting “Argument out of range” error
If the form is big enough to fit all the items it seems to be happy
If i take out the tv1.BeginUpdate and tv1.EndUpdate it sometimes works but still get the Argument out of range error randomly
procedure TfrmMain.btn1Click(Sender: TObject);
var i : Integer;
begin
tv1.Clear;
tv1.BeginUpdate;
try
for I := 0 to 10 do begin
with TTreeViewItem.Create( tv1 ) do begin
Parent := tv1;
Text := inttostr(i);
end;
end;
finally
tv1.EndUpdate;
end;
end;
Here is an example project
https://github.com/dangas56/Delphi-XE8-TreeNode-ArgumentOutOfRange-Error
Remember to click the basic fill button twice
EDIT: If anyone can suggest another component that allows you to expand and collapse sub-items please let me know