【发布时间】:2013-04-11 06:36:20
【问题描述】:
我有一个问题,设计师没有将继承的ContextMenuStrip 添加到components。以下是重现问题的方法:
- 创建新项目(Windows 窗体应用程序)。
-
通过设计器添加到表单
ContextMenuStrip,它将生成:private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); ... } -
创建
MyContextMenuStrip类:public class MyContextMenuStrip : ContextMenuStrip { } -
通过设计器编译并添加到表单
MyContextMenuStrip,它将生成:private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); this.myContextMenuStrip1 = new WindowsFormsApplication1.MyContextMenuStrip(); ... }
WTF?为什么不给组件添加MyContextMenuStrip???
我需要在components 中为我的本地化经理提供菜单(以自动翻译菜单)。我是否忘记了某些属性、接口或覆盖?
【问题讨论】:
标签: winforms designer contextmenustrip