Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6133755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:16:07+00:00 2026-05-23T17:16:07+00:00

When i am adding node in treeview after selecting any node some time its

  • 0

When i am adding node in treeview after selecting any node some time its adding and some time item not adding and giving an error Index must be within the bounds of the List. Parameter name: index

Code i am following is

public void AddWorkflowItem()
        {
            DeletePageNoFromContentTreeView();
            string ToolTips = null;
            if (baseCase.LockUser == null)
            {
                View.ResultOperation.Message =
                    "Case has been unlocked by ACR Production Specialist. System is unable to save changes.";
                View.ResultOperation.IsSuccessfully = false;
                return;
            }
            if (baseCase.LockUser.Id != AuthenticationService.CurrentUser.Id)
            {
                View.ResultOperation.Message =
                    new StringBuilder("Case has been locked by ")
                        .Append(baseCase.LockUser.Profile.Degree + " ")
                        .Append(baseCase.LockUser.Profile.FirstName + " ")
                        .Append(baseCase.LockUser.Profile.LastName + ". System is unable to save changes.")
                        .ToString();
                View.ResultOperation.IsSuccessfully = false;
                return;
            }
            CipCaseWorkflowItem newItem = null;
            ISet<CipCaseWorkflowItem> list = GetCaseWorkflow();
            CaseContentItemType selectedItem =
                (CaseContentItemType)
                Enum.Parse(typeof(CaseContentItemType), View.AddCaseContentItemTypeList.SelectedValue);
            ContentElementType selectedTextItem = ContentElementType.None;
            switch (selectedItem)
            {
                case CaseContentItemType.BaseCaseTextElement:
                    selectedTextItem =
                        (ContentElementType)
                        Enum.Parse(typeof(ContentElementType), View.AddCaseContentSubItemTypeList.SelectedValue);
                    //GetContentElementType(View.AddCaseContentSubItemTypeList.SelectedValue);//
                    newItem = new CipTextElementScriptItem(cipCase, selectedTextItem);
                    newItem.Type = selectedItem;
                    newItem.IsEmpty = true;
                    break;
                case CaseContentItemType.TemplatedItem:
                    CaseContentTemplatedItemType selectedTemplateItem =
                        (CaseContentTemplatedItemType)
                        Enum.Parse(typeof(CaseContentTemplatedItemType),
                                   View.AddCaseContentSubItemTypeList.SelectedValue);
                    //newItem = new CipTemplatedScriptItem(cipCase, selectedTemplateItem);
                    newItem = CreateCipWorkflowTemplatedItem(cipCase, selectedTemplateItem);
                    newItem.IsEmpty = false;
                    break;
                case CaseContentItemType.Question:
                    newItem = new CipQuestionScriptItem(cipCase);
                    ((CipQuestionScriptItem)newItem).ColumnsNo = 1;
                    newItem.Type = selectedItem;
                    if (View.AddActiveView == CaseContentAddActiveView.NoQuestions)
                    {
                        newItem.IsEmpty = true;
                        ToolTips = string.Empty;
                    }
                    else
                    {
                        int questionId = Int32.Parse(View.AddQuestionList.SelectedValue);
                        QuestionElement question = FindQuestionById(questionId);
                        ((CipQuestionScriptItem)newItem).QuestionElement = question;
                        newItem.IsEmpty = false;
                        ToolTips = question.GetToolTip();
                    }
                    break;
                case CaseContentItemType.CaseCredits:
                case CaseContentItemType.PageBreak:
                case CaseContentItemType.CIPCMEGraphic:
                case CaseContentItemType.CaseAuthours:
                case CaseContentItemType.CMEInfo:
                case CaseContentItemType.PostTest:
                case CaseContentItemType.EmptyLine:
                case CaseContentItemType.HorizontalLine:
                    newItem = new CipCaseWorkflowItem(cipCase, selectedItem);
                    newItem.IsEmpty = false;
                    break;
                    case CaseContentItemType.Image:
                    newItem = new CipImageScriptItem(cipCase);
                    newItem.IsEmpty = false;                    
                    break;
                default:
                    throw new ApplicationException("Invalid context item type.");
            }
            TreeNode selectedNode = contentTreeView.SelectedNode;
            newItem.IsHidden = false;
            //TreeNode rootNode = contentTreeView.Nodes[0];
            if ((selectedNode != null) && !string.IsNullOrEmpty(selectedNode.Value))
            {
                CaseContentItemType itemType;
                ContentElementType textElementType;
                CaseContentTemplatedItemType templatedItemType;
                int id;
                string nodeId = selectedNode.Value;
                ParseNodeId(nodeId, out itemType, out textElementType, out templatedItemType, out id);
                CipCaseWorkflowItem current = FindSelectedItemIdById(id);
                int newItemSortField = current.SortField + 1;
                newItem.SortField = newItemSortField;
                IncreaseSortIndex(newItemSortField);
                cipCase.WorkflowItems.Add(newItem);
            }
            else
            {
                int maxIndex;
                GetMaxIndex(list, out maxIndex);
                maxIndex++;
                newItem.SortField = maxIndex;
                cipCase.WorkflowItems.Add(newItem);
            }
            if (selectedItem != CaseContentItemType.Question)
                FindAndAttachSingleItem(selectedItem, selectedTextItem, newItem, out ToolTips);
            baseCase.LastEditedDate = DateTime.Now;
            Ioc.Resolve<IWebSessionManager>().CurrentSession.Flush();
            TreeNode newNode = CreateTreeNode(newItem, null);
            if (ToolTips != null)
                newNode.ToolTip = AddContentItemStateToToolTip(newItem.IsHidden, ToolTips);
            else
                newNode.ToolTip = AddContentItemStateToToolTip(newItem.IsHidden, string.Empty);
            if (selectedNode != null)
                contentTreeView.Nodes.AddAt(newItem.SortField, newNode);
            else
                contentTreeView.Nodes.Add(newNode);
               SetWorkflowActionButtonState();
            if (selectedItem == CaseContentItemType.CaseCredits)
                SetupAddCombos();
            if (selectedItem == CaseContentItemType.Question)
                SetupSubItemCombo(selectedItem);

            DeletePageNoFromContentTreeView();
            SetupPagenumbersToContentTreeView();
            if (selectedItem == CaseContentItemType.Image)
            {
                SetupPageForSelectedNode(newNode);
                //View.AddActiveView = CaseContentAddActiveView.Images;
            }

            newNode.Select();
            SetupPageForSelectedNode(newNode);
            SetWorkflowActionButtonState();
        }

protected void IncreaseSortIndex(int sortIndex)
{

foreach (CipCaseWorkflowItem item in cipCase.WorkflowItems)
    {
        if (item.SortField >= sortIndex)
        item.SortField++;
      }

}

error is coming in this line

  if (selectedNode != null)
                contentTreeView.Nodes.AddAt(newItem.SortField, newNode);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:16:08+00:00Added an answer on May 23, 2026 at 5:16 pm

    Call this function before the call of DeletePageNoFromContentTreeView();

        protected void ResortWorkflowItems()
        {
            int i = 0;
            foreach (CipCaseWorkflowItem item in cipCase.WorkflowItems)
                item.SortField = i++;
            baseCase.LastEditedDate = DateTime.Now;
            Ioc.Resolve<IWebSessionManager>().CurrentSession.Flush();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my treeview, after adding a fold, I want that row to be highlghted
I have a Treeview where on selecting a node the attributes and values has
TreeNode[] nodes = this.treeview.Nodes.Find(node.Text, true); if (nodes.Length > 0) { int i = nodes[0].Index;
I am looking for a recipe for adding Drupal node records. I have identified
Adding the row one by one in the button click.. (i tried but its
When adding an EditItemTemplate of some complexity (mulitple fields in one template), and then
I'm adding new content to a node, but I'm stuck on what to put
I'm adding some pictures to my Drupal files folder. I was wondering if Drupal
I have a treeview using BackGround worker to add nodes when you expand any.
Which XML structure allows me faster adding,deleting,updating of a node? My assumption is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.