在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
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(); } |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论