I try the one of your approach, it works well in my computer. Below is my code:

 public void AddContextMenu()
{
ContextMenu mnuContextMenu = new ContextMenu();
mnuContextMenu.MenuItems.Add("&Red LED", new EventHandler(SetDisplayRed));
mnuContextMenu.MenuItems.Add("&Blue LED", new EventHandler(SetDisplayBlue));
mnuContextMenu.MenuItems.Add("&LCD", new EventHandler(SetDisplayLCD));
textBox1.ContextMenu = mnuContextMenu;
this.ContextMenu = mnuContextMenu;
} private void SetDisplayRed(object sender, EventArgs e)
{ textBox1.BackColor = Color.Maroon;
textBox1.ForeColor = Color.OrangeRed;
} private void SetDisplayBlue(object sender, EventArgs e)
{
textBox1.BackColor = Color.Red;
textBox1.ForeColor = Color.Gray;
} private void SetDisplayLCD(object sender, EventArgs e)
{
textBox1.BackColor = Color.Beige;
textBox1.ForeColor = Color.Blue;
}

>When I right-click on the textbox I get a menu with Undo/Cut/Copy/Paste/Select All.  And when I right-click on the form I get nothing

Have you already added your "AddContextMenu()" method into the contruction method of your mainform?

public MainForm()
{
InitializeComponent(); AddContextMenu();
}

create a C# context menu from code的更多相关文章

  1. create Context Menu in Windows Forms application using C# z

    In this article let us see how to create Context Menu in Windows Forms application using C# Introduc ...

  2. SAP Context menu(菜单)

    *&---------------------------------------------------------------------* *& Report RSDEMO_CO ...

  3. Android Contextual Menus之一:floating context menu

    Android Contextual Menus之一:floating context menu 上下文菜单 上下文相关的菜单(contextual menu)用来提供影响UI中特定item或者con ...

  4. Tree Context Menu

    Right click on a node to display context menu.   My Documents Photos Program Files Intel Java Micros ...

  5. Win7/Win8右键菜单管理工具(Easy Context Menu) v1.5 绿色版

    软件名称: Win7/Win8右键菜单管理工具(Easy Context Menu)软件语言: 简体中文授权方式: 免费软件运行环境: Win8 / Win7 / Vista / WinXP软件大小: ...

  6. Description Resource Path Location Type Project configuration is not up-to-date with pom.xml. Select: Maven->Update Project... from the project context menu or use Quick Fix. spark-MT line 1 Maven Co

    1.相信大家新建的maven项目,然后添加好依赖(即修改了pom.xml文件以后就会出现如下所示的错误): Description Resource Path Location Type Projec ...

  7. sublime text 3-right click context menu

    dd a system wide windows explorer button " Edit with Sublime" similar to how Notepad++ doe ...

  8. 手机浏览器中屏蔽img的系统右键菜单context menu

    我们知道通过oncontextmenu事件可以屏蔽浏览器右键菜单 $('img').on("contextmenu",function(E){E.preventDefault(); ...

  9. Android -- Options Menu,Context Menu,Popup Menu

    Options Menu                                                                           创建选项菜单的步骤: 1. ...

随机推荐

  1. Windows.Andy.Code4App.dll Win8.1/WP8.1通用类库@ver1.0.1

    在上篇 Windows.Andy.Code4App.dll  Win8.1/WP8.1通用类库@ver1.0.0 已经对Win8.1和WP8.1部分扩展通用类库做了说明,这篇继续对通用类库做扩展.写的 ...

  2. Cocos2dx隐藏iOS7状态栏】通过添加Plist Key隐藏iOS7状态栏

    本站文章均为李华明Himi原创,转载务必在明显处注明:(作者新浪微博:@李华明Himi)  转载自[黑米GameDev街区] 原文链接: http://www.himigame.com/%e9%9a% ...

  3. [SQL SERVER系列]存储过程,游标和触发器实例[原创]

    自己写的存储过程与游标结合使用的实例,与大家分享,也供自己查阅,仅供参考: --使用游标循环处理,删除重复的记录 declare @UserID int ) ) declare @UnitFlag i ...

  4. tableView中不易被注意到的方法

    - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ } 这个方法 在 r ...

  5. redhat_suse双系统引导

    先装suse11系统,再装redhat6后出现引导中suse系统无法启动解决方法:在redhat中将suse所在分区挂载出来,找其boot/grub/menu.lst下的启动项,将该启动项复制到red ...

  6. sqlmap映射继承机制及映射字段顺序与SQL查询字段顺序无关

    <typeAlias alias="TblSpPartsinfo" type="com.bn.car.biz.supply.dao.po.PartsInfoPO&q ...

  7. CF 136B Ternary Logic

    http://codeforces.com/problemset/problem/136/B 题意 :就是说tor是一个三进制的运算,代表的是两个三进制数的运算,两个三进制数按位逐一相加后对三取余,没 ...

  8. windows8 64位 IIS8 PHP5.5 安装 Imagemagick 组件

    为什么这里一定要说 windows 系统是64位呢,因为如果是系统是64位,那么PHP5.5 一般都会选择64的, Imagemagick 组件也会选择64位的, 但是操蛋的是 64位的Imagema ...

  9. 利用Spring AOP自定义注解解决日志和签名校验

    转载:http://www.cnblogs.com/shipengzhi/articles/2716004.html 一.需解决的问题 部分API有签名参数(signature),Passport首先 ...

  10. iOS开发--TableView详细解释

    -.建立 UITableView  DataTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 420)];  [Data ...