我想在一个窗体里面实现一个单击右键的时候弹出一个快捷菜单,但是编译的时候出错,不知道为什么,
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace testAPP
{
public partial class Form1 : Form
{
System.Windows.Forms.ContextMenu cms;
Label l1;
public Form1()
{
cms = new ContextMenu();
cms.MenuItems.Add("baidu");
cms.MenuItems.Add("google");
this.Controls.AddRange(new System.Windows.Forms.Control[] {this.cms});
}
static void Main()
{
Application.Run(new Form1());
}
}
}
错误 1 无法将类型“System.Windows.Forms.ContextMenu”隐式转换为“System.Windows.Forms.Control” E:\C# Project\testAPP\testAPP\Form1.cs 22 72 testAPP
是什么原因呀?本人是刚开始学C#的,所以请多多指教~~