Hi There,
I'm trying to add elements into a package in a particular order, but not having much luck. I understand the TreePos property needs to be set, but it does not appear to be having the effect. If this code below worked as I wanted it to, it would add 3 classes to a package with the order "Charlie, Baker, Adams". Instead it comes up "Adams, Baker Charlie" in EA. I can re-sort them manually, but I want this to be automatic.
Dim thisPackage As Package
thisPackage = earepository.GetPackageByGuid("{22926A63-B111-45cf-94D4-49081E77E6A6}")
Dim newElement As Element
newElement = thisPackage.Elements.AddNew("Charlie", "Class")
newElement.TreePos = 1
newElement.Update()
newElement = thisPackage.Elements.AddNew("Baker", "Class")
newElement.TreePos = 2
newElement.Update()
newElement = thisPackage.Elements.AddNew("Adams", "Class")
newElement.TreePos = 3
newElement.Update()
I've tried various refresh and update commands on the package and the connectors, but to no avail. I've also tried multiple values for TreePos. I feel like I must be missing something basic, so can anyone shed light on this for me?