C# 窗体运行时上下文菜单项不显示

C# 窗体运行时上下文菜单项不显示,c#,windows,winforms,C#,Windows,Winforms,我已经在windows窗体应用程序上创建了上下文菜单项。但当我运行应用程序并尝试右键单击时,创建的菜单项不会显示出来 我的代码: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks

我已经在windows窗体应用程序上创建了上下文菜单项。但当我运行应用程序并尝试右键单击时,创建的菜单项不会显示出来

我的代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication7
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
}

您必须在表单或任何希望与之关联的控件上设置
ContextMenuStrip
属性:


您应该将其分配给表单的
ContextMenuStrip
属性。