将 TrackBar 控件添加到 ContextMenu
是否可以将 TrackBar 控件添加到 ContextMenu?因此,当我右键单击时,我的上下文菜单将下拉并且轨迹栏将显示为菜单项?
Is it possible to add a TrackBar control to a ContextMenu? So when I right click, my ContextMenu will drop down and a TrackBar will appear as a menu item?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您的上下文菜单是
ContexMenuStrip
,您可以通过以下方式创建项目:借助
ToolStripItemDesignerAvailability
属性,您甚至可以在表单设计器中看到该项目,如图所示如下图中:PS
此解决方案来自此 MSDN 示例
If your context menu is a
ContexMenuStrip
, you can create an item in this way:Thanks to the
ToolStripItemDesignerAvailability
attribute, you can even see the item in the Forms Designer, as shown in the image below:P.S.
This solution comes from this MSDN example
是的,您需要将上下文菜单设置为用户绘制并自己绘制菜单项。您必须创建一个自定义 MenuItem 来实现 TrackBar
Yes, you need to set the context menu to user draw and draw the menu items yourself. You will have to create a custom MenuItem the implementes a TrackBar
对于任何偶然发现此问题的人来说,这是值得的:
我让它工作的唯一方法是将派生控件放入它自己的文件中。当它与另一个控件位于同一文件中时,它会让设计者感到困惑。
For what it's worth for anyone who stumbles across this having problems with:
The only way I got it to work was by putting the derived control in it's own file. When it is in the same file as another control it confuses the designer.