diff --git a/PROMS/VEPROMS.CSLA.Library/VEObjects/VETreeNode.cs b/PROMS/VEPROMS.CSLA.Library/VEObjects/VETreeNode.cs index 0169fcf3..45d3da41 100644 --- a/PROMS/VEPROMS.CSLA.Library/VEObjects/VETreeNode.cs +++ b/PROMS/VEPROMS.CSLA.Library/VEObjects/VETreeNode.cs @@ -497,13 +497,33 @@ namespace VEPROMS.CSLA.Library } void myItemInfo_NewSiblingBefore(object sender, ItemInfoInsertEventArgs args) { - if(this.Parent != null) // Only do this if the node has a parent - RHM 20100106 - this.Parent.Nodes.Insert(Index,(new VETreeNode(args.ItemInserted))); + if (this.Parent != null) // Only do this if the node has a parent - RHM 20100106 + { + ItemInfo ii = args.ItemInserted as ItemInfo; + if (ii == null) + this.Parent.Nodes.Insert(Index, (new VETreeNode(args.ItemInserted))); + else // B2020-142: Can't get properties of restored item (no treeview context menu would be correct after restore) + { + if (ii.IsProcedure) this.Parent.Nodes.Insert(Index, (new VETreeNode(ProcedureInfo.Get(ii.ItemID)))); + if (ii.IsSection) this.Parent.Nodes.Insert(Index, (new VETreeNode(SectionInfo.Get(ii.ItemID)))); + if (ii.IsStep) this.Parent.Nodes.Insert(Index, (new VETreeNode(StepInfo.Get(ii.ItemID)))); + } + } } void myItemInfo_NewSiblingAfter(object sender, ItemInfoInsertEventArgs args) { if (this.Parent != null) // Only do this if the node has a parent - RHM 20100106 - this.Parent.Nodes.Insert(Index + 1, (new VETreeNode(args.ItemInserted))); + { + ItemInfo ii = args.ItemInserted as ItemInfo; + if (ii == null) + this.Parent.Nodes.Insert(Index + 1, (new VETreeNode(args.ItemInserted))); + else // B2020-142: Can't get properties of restored item (no treeview context menu would be correct after restore) + { + if (ii.IsProcedure) this.Parent.Nodes.Insert(Index + 1, (new VETreeNode(ProcedureInfo.Get(ii.ItemID)))); + if (ii.IsSection) this.Parent.Nodes.Insert(Index + 1, (new VETreeNode(SectionInfo.Get(ii.ItemID)))); + if (ii.IsStep) this.Parent.Nodes.Insert(Index + 1, (new VETreeNode(StepInfo.Get(ii.ItemID)))); + } + } } public VETreeNode(string s) : base(s)