Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.

Public Report
Report From: Kylix/VCLX/TTreeView    [ Add a report in this area ]  
Report #:  11626   Status: Reported
Item Index Wrong Assignment
Project:  Kylix Build #:  1
Version:    3.0 Submitted By:   Francisco Silva
Report Type:  Issue Date Reported:  3/26/2005 8:44:55 AM
Severity:    Serious / Highly visible problem Last Updated: 3/26/2005 9:21:32 AM
Platform:    Kylix Pascal IDE Internal Tracking #:  
Resolution: None  Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
Description
When I have a TreeView with some Items in it, if I try to Insert a new item the new Item gets the next available Index and NOT the NEXT Index of where I inserted. But if I call the AbsoluteIndex function I DO get the right Index. But the issue here is that the Absolute Index of an Item is NOT the same as the TRUE Index of the Item in the TreeView.

For example:

- one        (Absolute index = 0)
   - two        (Absolute index = 1)
   - three        (Absolute index = 2)
   - four        (Absolute index = 3)

now lets say that I want to Insert a new Item between "two and three"

- one        (Absolute index = 0)         real Index =0
   - two        (Absolute index = 1)      real Index =1
   - NewItem   (Absolute index = 2)      real Index =4
   - three        (Absolute index = 3)      real Index =2
   - four        (Absolute index = 4)      real Index =3

If I want to Access directly the "NewItem" I should type:
Caption := TreeVew1.Items[2].Text;
this should show the text of the newItem in the Form Title, but it dosn't, It will show the Text of the Item "three";
Steps to Reproduce:
None
Workarounds
the only way I could access the Item I wanted is:

var
  i : Integer;
  sNode : TTreeNode;
begin
    sNode := TreeView1.Items[0];
    for i:=0 to StrToInt(MaskEdit1.Text) do
        if sNode.GetNext <> nil then
           sNode := sNode.GetNext
        else
        begin
            sNode := nil;
            Exit;
        end;
    TreeView1.Selected := sNode;
end;


doing this does work accuratly, but when I have a treeView with much more items then these is very slow.

My Application some times has arround 1000 Items, and when I want to select one of the last items this will make look my app slow.
Attachment
treeInsert.zip
Comments

None

Server Response from: ETNACODE01