Great!! It has worked. But encountered a new issue with this.
Want to know that when I right click on a node, I have four layout configuration options(Alternating, Layered, RootOnly, LastParent) as menu items. I select Alternating for the sub tree. As per your solution, I added this right clicked node as a Root in TreeLayout.Roots. Did all what you said.
OrgChartTreeLayout.Roots.Add(rootNode);
IEnumerable subTreeParts = rootNode.FindTreeParts(EffectiveCollectionInclusions.SubTree);
IEnumerable nodes = subTreeParts.OfType().Cast();
IEnumerable links = subTreeParts.OfType().Cast();
OrgChartTreeLayout.DoLayout(nodes, links);
But how would my subtree know which layout configuration i selected. If I am doing this:
TreeLayout.TreeStyle = treeStyle;
Here treeStyle is the selected menu item(ie. Alternating), then it applies this configuration onto complete tree.
The code shown below is my actual code:
OrgChartTreeLayout.Roots.Add(rootNode);
IEnumerable subTreeParts = rootNode.FindTreeParts(EffectiveCollectionInclusions.SubTree);
IEnumerable nodes = subTreeParts.OfType().Cast();
IEnumerable links = subTreeParts.OfType().Cast();
switch (treeStyle)
{
case TreeStyle.Layered:
OrgChartTreeLayout.AlternatePortSpot = Spot.BottomCenter;
OrgChartTreeLayout.AlternateChildPortSpot = Spot.MiddleTop;
break;
case TreeStyle.LastParents:
OrgChartTreeLayout.AlternatePortSpot = new Spot(0, 1, 20, 0);
OrgChartTreeLayout.AlternateChildPortSpot = Spot.MiddleLeft;
break;
case TreeStyle.Alternating:
OrgChartTreeLayout.AlternatePortSpot = new Spot(0, 1, 20, 0);
OrgChartTreeLayout.AlternateChildPortSpot = Spot.MiddleLeft;
break;
case TreeStyle.RootOnly:
OrgChartTreeLayout.AlternatePortSpot = new Spot(0, 1, 20, 0);
OrgChartTreeLayout.AlternateChildPortSpot = Spot.MiddleLeft;
break;
}
OrgChartTreeLayout.PortSpot = Spot.BottomCenter;
OrgChartTreeLayout.ChildPortSpot = Spot.MiddleTop;
OrgChartTreeLayout.SetsPortSpot = true;
OrgChartTreeLayout.SetsChildPortSpot = true;
OrgChartTreeLayout.AlternateSetsPortSpot = true;
OrgChartTreeLayout.AlternateSetsChildPortSpot = true;
OrgChartTreeLayout.Arrangement = TreeArrangement.FixedRoots;
OrgChartTreeLayout.TreeStyle = treeStyle;
OrgChartTreeLayout.DoLayout(nodes, links);
Please help me out!!
Thanks!!