diff --git a/PROMS/Volian.Controls.Library/vlnTreeView.cs b/PROMS/Volian.Controls.Library/vlnTreeView.cs index 0ab3475d..43654113 100644 --- a/PROMS/Volian.Controls.Library/vlnTreeView.cs +++ b/PROMS/Volian.Controls.Library/vlnTreeView.cs @@ -730,7 +730,9 @@ namespace Volian.Controls.Library void mi_Click(object sender, EventArgs e) { - MenuItem mi = (MenuItem)sender; + MenuItem mi = sender as MenuItem; + if (mi == null) + return; switch (mi.Text) { case "Open": @@ -1163,7 +1165,7 @@ namespace Volian.Controls.Library if (!hasMetaSubs) doPseudo = true; } } - using (Section section = Section.MakeSection(_LastItemInfo, _LastItemInfo.LastChild(E_FromType.Section), null, "New Section", 10000)) + using(Section section = CreateNewSection()) { ShowBrokenRules(section.BrokenRulesCollection); SetLastValues(SectionInfo.Get(section.ItemID)); @@ -1262,7 +1264,13 @@ namespace Volian.Controls.Library OnNodeInsert(this, new vlnTreeEventArgs(SelectedNode)); } } - + private Section CreateNewSection() + { + if(_LastItemInfo.LastChild(E_FromType.Section) != null) + return Section.MakeSection(_LastItemInfo, _LastItemInfo.LastChild(E_FromType.Section), null, "New Section", 10000); + ItemInfo iii = _LastItemInfo.InsertChild(E_FromType.Section, 10000, "New Section", null); + return Section.Get(iii.ItemID); + } private VETreeNode InsertChildStep(VETreeNode tn) { // If parent step is open in editor, use the OnInsertItemInfo to insert step & add RTBItems to step editor panel