Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

Insert Item levels

I am inserting items in a tree, using manual drag/drop.
The level I have in the recipient tree has a level 2 which I am inserting into.
On the insert, the new item is defined as a level 3, but it is being inserted as a level 2.

If I obtain the tree after the insert it shows a 2.

Is there a specific way of doing things to get the item to be inserted as a child.

Example code below, which is just inserting one line.


Pos+=1 NewItems<Pos,1>=3 NewItems<Pos,2>=DragKey NewItems<Pos,3>=DragItem<1> NewItems<Pos,4>=DragItem<2> NewItems<Pos,5>=DragItem<3> Call Send_Message(CurrCtrl,"OLE.InsertItems",DropAssetKey,NewItems,"After")


  • Colin,

    Your syntax looks correct to me, at least according to the docs. Just a couple clarifying questions:
    • You are positive that the level of DropAssetKey is 2? I am not trying to ask you to suck eggs, but I have come across too many scenarios where the customer made an assumption that was, in fact, wrong.
    • When you are done with the operation, does the NewItems item appear before or after the DropAssetKey item?

    Also, just as an experiment, what happens if you set the level to some much higher, like 8?
  • Don,

    I would be more than happy to be shown to have made a mistake.
    I can imagine the number of times this could happen, as the situations are complex, and I am just getting a handle on the drag/drop functionality.

    I tried level 8, and it made no difference.
    I also tried level 1, as the example for AddItems shows these being set to level 1, even though its being added to a higher level branch (Blue Team). I am assuming InsertItems and AddItems are one and the same.

    See attached screen shot where you can see the debug with the variable set to 3, and the tree obtained afterwards with the level set to 2.

    Hope things helps, but feel free to bash me over the head and tell me to go away if I have it wrong.


  • Sorry for the delayed response. InsertItems will always insert the items as siblings, not as children. The only reason the index value is available is so you can insert a mini-tree before or after an item. The first item's level becomes the base level, which is 3 in your case. If you were inserting multiple items at once and wanted the second one to be a child of the first, then your second item's level would be 4.

    The rule of thumb is this: if you want to place an item before or after another item, use InsertItems. If you want to add an item as a child to another item, use AddItems. AddItems always adds the item to the end of the children (unless the parent is set to sort).
  • Thanks.
    I now see the subtle differences in the documentation between AddItem and InsertItem methods.
    Things are complex with what I am trying to achieve, so I am now changing this to a locate/insert into the full tree and repopulate the tree, so that I have better control.

  • So I used this post to confirm that I need to be using AddItems instead of InsertItems but...
    My list does get added as a child of the destination item as desired, however all items in the additems list also get added as children of the first item being added.

    What I'm after is, I have a potential parent in the list (no children yet). I want to give that item a bunch of children at the same time; quintuplets if you like. All the children should be of the same level but they are being added as quadruplets grandchildren with their first sibling as their parent.

    here's the list to add, note all items are level 2

    Upon adding, the first one is added as a level 2 and the rest are added as level 3 and therefore children of the first one

    visually looking like this

    All those dates should be directly underneath each other.

  • Try passing 1 as the level for all the children.
Sign In or Register to comment.