| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 471 人关注过本帖
标题:[求助]关于快捷菜单问题
只看楼主 加入收藏
winsun
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2007-3-4
收藏
 问题点数:0 回复次数:2 
[求助]关于快捷菜单问题

我想在一个窗体里面实现一个单击右键的时候弹出一个快捷菜单,但是编译的时候出错,不知道为什么,
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#的,所以请多多指教~~

搜索更多相关主题的帖子: 菜单 
2007-03-21 12:34
缘来
Rank: 1
等 级:新手上路
帖 子:135
专家分:0
注 册:2006-11-18
收藏
得分:0 
帮顶一下,我最近也是在弄右键菜单问题,不过回答不了你的问题!

博客:http://hi.baidu.com/xiaotown欢迎大家一起交流!
2007-03-21 14:39
skyland84
Rank: 2
等 级:新手上路
威 望:4
帖 子:544
专家分:0
注 册:2006-10-9
收藏
得分:0 
无法将类型“System.Windows.Forms.ContextMenu”隐式转换为“System.Windows.Forms.Control”

针对你这个 错误 你可以

this.Controls.AddRange(new System.Windows.Forms.Control[] {(object)this.cms});



决定人生~
2007-03-21 14:55
快速回复:[求助]关于快捷菜单问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020928 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved