Tree node fixes when deleting nodes

This commit is contained in:
2010-01-15 17:05:41 +00:00
parent 61c9d01516
commit cdf14f6328
5 changed files with 120 additions and 82 deletions

View File

@@ -1637,9 +1637,12 @@ namespace Volian.Controls.Library
{
// start at the top parent and walk down the nodes to find child
VETreeNode node = FindNodeAndExpand(selectedItem);
_AdjustingTree = true;
this.SelectedNode = node;
_AdjustingTree = false;
if (node != null)
{
_AdjustingTree = true;
this.SelectedNode = node;
_AdjustingTree = false;
}
}
public VETreeNode FindNodeAndExpand(IVEDrillDownReadOnly selectedItem)
{
@@ -1648,15 +1651,23 @@ namespace Volian.Controls.Library
return (VETreeNode)this.Nodes[0]; // Return the top node
}
VETreeNode parent = FindNodeAndExpand(selectedItem.ActiveParent);
if (parent == null) return null;
if (!parent.IsExpanded)
parent.Expand();
foreach (VETreeNode child in parent.Nodes)
if (CompareVEObject(child.VEObject, selectedItem))
foreach (TreeNode childNode in parent.Nodes)
{
VETreeNode child = childNode as VETreeNode;
if (child != null && CompareVEObject(child.VEObject, selectedItem))
return child;
foreach (VETreeNode child in parent.Nodes)
foreach (VETreeNode grandchild in child.Nodes)
if (CompareVEObject(grandchild.VEObject, selectedItem))
return grandchild;
}
foreach (TreeNode childNode in parent.Nodes)
{
VETreeNode child = childNode as VETreeNode;
if (child.VEObject is PartInfo)
foreach (VETreeNode grandchild in child.Nodes)
if (CompareVEObject(grandchild.VEObject, selectedItem))
return grandchild;
}
return null;
}
public bool CompareVEObject(IVEDrillDownReadOnly obj1, IVEDrillDownReadOnly obj2)