Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I am developing a common smartTag panel and deriving the base smartTag form my project. I want to add the existing action items of base smarttag in derived smart tag. I want to add the items of base panel below the items of derived panel. Is there any easy way to add the base items without foreach directly below the action items?

public override DesignerActionItemCollection GetSortedActionItems()
{
    DesignerActionItemCollection actionItems = new DesignerActionItemCollection();

    //adds the new smart tag action items.
    actionItems.Add(new DesignerActionHeaderItem("MySmartTag Support"));
    actionItems.Add(new DesignerActionPropertyItem("BackColor", "Back Color"));
    actionItems.Add(new DesignerActionPropertyItem("ForeColor", "Fore Color"));

    //adds the action items from base smart tag.
    foreach (DesignerActionItem baseItem in base.GetSortedActionItems())
    {
        actionItems.Add(baseItem);
    }
    return actionItems;
}


I am adding the base action items below the new action items with for loop, is there any way to avoid the loop and minimize the code?

Thanks and Regards,
Amal Raj

What I have tried:

I have tried to add the existing base items with for loop. let me know how to avoid loop.
Posted
Updated 2-Jan-17 18:07pm

1 solution

I have found the answer, inserting is the best option.

public override DesignerActionItemCollection GetSortedActionItems()
{
   DesignerActionItemCollection actionItems = base.GetSortedActionItems();

   //inserts the new smart tag action items.
   actionItems.Insert(0, new DesignerActionHeaderItem("MySmartTag Support"));
   actionItems.Insert(1, new DesignerActionPropertyItem("BackColor", "Back Color"));
   actionItems.Insert(2, new DesignerActionPropertyItem("ForeColor", "Fore Color"));

   return actionItems;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900