在C#中将现有的actionitems添加到新的actionit

在C#中将现有的actionitems添加到新的actionit

本文介绍了如何在C#中将现有的actionitems添加到新的actionitems的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我正在开发一个常见的智能标签面板并从我的项目中获取基础smartTag。我想在派生智能标记中添加基础智能标记的现有操作项。我想在派生面板的项目下面添加基本面板的项目。有没有简单的方法可以在行动项目下方直接添加基础项目?



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;
}





我在for循环的新操作项下添加基本操作项,有什么办法可以避免循环并最小化代码?



谢谢和问候,

Amal Raj



我尝试了什么:



我试图用for循环添加现有的基本项目。让我知道如何避免循环。



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.

推荐答案

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;
}


这篇关于如何在C#中将现有的actionitems添加到新的actionitems的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 22:12