右键单击图片框上的显示上下文菜单

编程入门 行业动态 更新时间:2024-10-26 18:15:29
本文介绍了右键单击图片框上的显示上下文菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何获得一个Contextmenu右键单击Windows应用程序中的图片框。必须显示所有图片框的相同上下文菜单。

How can I get a Contextmenu on Right click the picture box in windows application.The same contextmenu has to display for all the picture boxes.

推荐答案

试试这个.. try this.. pictureBox1.ContextMenustrip=contextMenuStrip1;

这不是这很难,但很容易忘记。 例如,假设您有一个图片框,并且您已经在其上绘制了一些内容,并希望用户能够在选择某个内容时拥有一个上下文菜单,而不是选择。您可以在选择/未选择内容时为上下文菜单指定图片框。或者你可以在右键单击显示它们菜单。 我在这里显示第二件事因为我发现维护时不易出错,只是我个人的选择。 在任何一种情况下,你都要创建一个上下文菜单对象,填写它,创建处理程序等。 This isn't that hard, but easy to forget. For example, lets say you have a picture box, and you have drawn things on it and want the user to be able to have a context menu for when a thing is selected and a different one when not selected. You could assign the picture box the context menu as things are selected / not selected. Or you could do it on the right click show them menu. I'm showing that second thing here because I find it less error prone when maintaining, just my personal choice. In either case you'd create a context menu object, fill it in, create the handlers, etc. if (e.Button == MouseButtons.Right) { mPointWhenClicked = new Point(e.X, e.Y); if (mObjectAlreadySelectedInImage != null) { contextMenuWhenSelected.Show(pictureBox1, e.X, e.Y); } else { contextMenuWhenNotSelected.Show(pictureBox1, e.X, e.Y); } }

更多推荐

右键单击图片框上的显示上下文菜单

本文发布于:2023-08-06 05:11:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1310269.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:右键   上下文   单击   菜单   图片

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!