Verify that the current node is within range before looking at the value

This commit is contained in:
Rich 2015-08-05 12:38:40 +00:00
parent f8c047e0c7
commit 94a1c4289b

View File

@ -2050,7 +2050,7 @@ namespace Volian.Controls.Library
if (OnNodeOpenProperty(this, new vlnTreePropertyEventArgs("New Section", section.SectionConfig)) == DialogResult.OK)
{
int indx = tvindex + ((newtype == MenuSelections.SectionBefore) ? 0 : 1);
if ((par.Nodes[indx] as VETreeNode).VEObject.ToString() != _LastSectionInfo.ToString())
if (indx >= par.Nodes.Count || (par.Nodes[indx] as VETreeNode).VEObject.ToString() != _LastSectionInfo.ToString())
{
tn = new VETreeNode(_LastSectionInfo);
par.Nodes.Insert(indx, tn);