views:

87

answers:

1

On my form I have a IWTreeView and two buttons. One button deletes some IWTreeViewItems, the other releases the form:

procedure TIWForm1.IWButton1Click(Sender: TObject);
begin
  IWTreeView1.Items[0].Subitems.Clear;
end;

procedure TIWForm1.IWButton2Click(Sender: TObject);
begin
  Release;
end;

Releasing the form after deleting the IWTreeViewItems causes an exception:

Error message raised by the application: Access violation at address 004E0D8A in module 'TryTree.exe'. Read of address 00000000

When there is another form active and the application is not terminated by this form release, the error message is:

Error message raised by the application: List index out of bounds (-1)

Using IntraWeb 9.0.42 (because of TMS controls and Delphi 2006, as TMS has not tested with 10.0.17 and delphi 2006).

I tried to IWTreeView1.ClearAll in the form destroy, which did not help at all.

A: 

Instead of SubItems.Clear I now use

for i := IWTreeView1.Items[0].SubItems.Count-1 downto 0 do begin
    TIWTreeViewItem(IWTreeView1.Items[0].SubItems[i]).Free;
end;

This works. Still open for better solutions, maybe not involving a loop through all subitems.

Ralph Rickenbach