Topic: List index out of bounds on Tree...

When there are no child nodes I get "List index out of bounds" while trying to add a node to tree.


Here is the script causing the issue:

procedure frmBMTree_OnClose (Sender: TObject; Action: string);
begin
If Form1.TreeView2.RowCount <> 0 then
   begin
   form1.TreeView2.collapseall;
   form1.TreeView2.expandnode(form1.TreeView2.selectedrow);
   form1.TreeView2.Expanded[form1.treeview2.selectedrow] := true;
   end;
end;

Error pointing to the following script line:

form1.TreeView2.expandnode(form1.TreeView2.selectedrow);

is there a way to trap it?

Adam
God... please help me become the person my dog thinks I am.

Re: List index out of bounds on Tree...

а так пробовали?
did you try that?

form1.TreeView2.expandnode(form1.TreeView2.selectedrow-1);

Re: List index out of bounds on Tree...

Hi pavlenko.vladimir.v,


Thank you very much for quick reply..............
Truly appreciated........
It seems that issue is solved.

Adam
God... please help me become the person my dog thinks I am.