ContextMenuStrip 在 Windows 左上角呈现
当我渲染 contextmenustrip 时,它会在我的电脑屏幕的左上角渲染。我有一个列表视图,其中包含 5-6 个项目,右键单击每个项目时,将显示上下文菜单条。此外,我还需要更改上下文菜单条的颜色,包括背景和文本。
提前致谢!
When i render contextmenustrip, it gets render at the top left of my PC Screen. I have a listview, which contains 5-6 items and on right click of each item, the context Menu strip gets displayed.Also i need to change the color of context menu strip including backgrounds and text as well.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
到目前为止,最简单的方法是将 ListView.ContextMenuStrip 属性设置为您的 CMS,然后一切都是自动的。您可以在设计器中执行此操作。
如果您出于某种原因需要自定义处理程序,例如检查是否单击了正确的项目,那么您可以使用如下代码调用 Show() 方法属性:
By far the simplest way is to just set the ListView.ContextMenuStrip property to your CMS, everything is automatic then. You can do so in the designer.
If you need a custom handler for some reason, to check if the right item was clicked for example, then you can call the Show() method property with code like this:
您尚未显示任何代码,但如果您没有调用将控件作为参数的
Show
重载,则您的new Point(0, 0)
显然通过会将菜单放在屏幕的左上角。You haven't shown any code, but if you're not calling the
Show
overload that takes a control as a parameter, thenew Point(0, 0)
that your obviously passing will put the menu in the upper left of the screen.