Не отображается элементы contextMenuStrip1 - C#
Формулировка задачи:
Дошел до темы контекстные меню. После дого как в конструкторе на форме заполнил toolStripMenuItem`ы
компелирую, при нажатии правой кнопкой мыши на форме контекст не отображается...
По логике когда создавал MenuStrip`ы с голыми текстами - оно отображалось, хоть и ничего при их нажатии не происходило, а contextMenuStrip1 не получается. Пример который вложен в МСДН работает, только я ничего не понимаю. Обработчик событий и так создаётся из коструктора. Помогите разобраться самоучке пожалуйста.
namespace ContextMenu
{
partial class Form1
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором форм Windows
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenuStrip1.SuspendLayout();
this.SuspendLayout();
//
// contextMenuStrip1
//
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItem2,
this.toolStripMenuItem3,
this.toolStripMenuItem4});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(153, 92);
this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip1_Opening);
//
// toolStripMenuItem2
//
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
this.toolStripMenuItem2.Size = new System.Drawing.Size(152, 22);
this.toolStripMenuItem2.Text = "&First";
//
// toolStripMenuItem3
//
this.toolStripMenuItem3.Name = "toolStripMenuItem3";
this.toolStripMenuItem3.Size = new System.Drawing.Size(152, 22);
this.toolStripMenuItem3.Text = "&Second";
//
// toolStripMenuItem4
//
this.toolStripMenuItem4.Name = "toolStripMenuItem4";
this.toolStripMenuItem4.Size = new System.Drawing.Size(152, 22);
this.toolStripMenuItem4.Text = "&Third";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 262);
this.Name = "Form1";
this.Text = "Form1";
this.contextMenuStrip1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem3;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem4;
}
}using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ContextMenu
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Cursor = Cursors.Help;
}
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
{
}
}
}
Извиняюсь за глупый вопрос, разобрался здесь:
http://dotnetperls.com/contextmenustrip-example
Это именно то о чём я хотел спросить, в моей книжке про это не слова(((....
Решение задачи: «Не отображается элементы contextMenuStrip1»
textual
Листинг программы
this.ContextMenuStrip = this.contextMenuStrip1;