我虽然没做过,但我有点思路,vs里大多数控件都有个属性可以设置该控件的右击菜单,估计多数是从control这继承来的,那你自己的控件肯定也要继承control把?那也有这个属性的,把这个属性设成你想要的context menu的name就可以了

解决方案 »

  1.   

    (月下的夜想曲) 你的办法是要再设计期加上一个 右键菜单 能不能修改ide 提供的那个并不是完全自己做???
      

  2.   

    此功能通过写设计器来实现。
    只要在设计器的加入DesignerVer就行了。参考ComponentDesigner的帮助文档。
      

  3.   

    ms-help://MS.VSCC/MS.MSDNVS.2052/cpguide/html/cpconwinformsdesignersample.htm的示例
      

  4.   

    不知道这个算不算?http://www.windowsforms.net/default.aspx?tabindex=4&tabid=47&ItemID=16&mid=142
      

  5.   

    写设计器了,有个什么Designer类(具体的忘了名了),它有方法能得到所有的Verbs集合,自己定义一个Verb实例,add到集合中就行了
      

  6.   

    在类似ControlDesigner的设计时类中添加:
    public override System.ComponentModel.Design.DesignerVerbCollection Verbs
    {
    get
    {
    DesignerVerbCollection v = new DesignerVerbCollection(); // Verb to add buttons
    v.Add(new DesignerVerb("&Add Button", 
                            new EventHandler(OnAddButton))); return v;
    }
    }private void OnAddButton(object sender, System.EventArgs e)
    {
    ColourButton button;
    IDesignerHost h = (IDesignerHost) GetService(typeof(IDesignerHost));
    DesignerTransaction dt;
    IComponentChangeService c = (IComponentChangeService)
    GetService(typeof(IComponentChangeService)); // Add a new button to the collection
    dt = h.CreateTransaction("Add Button");
    button = (ColourButton) h.CreateComponent(typeof(ColourButton));
    c.OnComponentChanging(MyControl, null);
    MyControl.Buttons.Add(button);
    c.OnComponentChanged(MyControl, null, null, null);
    dt.Commit();
    }