問題があります。どのデザイナーが継承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(); ... }
なんてこと?コンポーネントに追加されないのはなぜですかMyContextMenuStrip???
componentsまた、ローカリゼーション マネージャー (メニューを自動的に翻訳するため) にメニューを表示する必要があります。属性、インターフェース、またはオーバーライドを忘れていませんか??