添加的TrackBar控制到ContextMenu [英] Adding a TrackBar control to a ContextMenu
本文介绍了添加的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?
推荐答案
如果你的右键菜单是一个 ContexMenuStrip
,您可以创建这样一个项目:
If your context menu is a ContexMenuStrip
, you can create an item in this way:
[ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.MenuStrip |
ToolStripItemDesignerAvailability.ContextMenuStrip)]
public class TrackBarMenuItem : ToolStripControlHost
{
private TrackBar trackBar;
public TrackBarMenuItem():base(new TrackBar())
{
this.trackBar = this.Control as TrackBar;
}
// Add properties, events etc. you want to expose...
}
感谢 ToolStripItemDesignerAvailability
属性,你甚至可以看到该项目中的窗体设计器,如下面的图所示:
Thanks to the ToolStripItemDesignerAvailability
attribute, you can even see the item in the Forms Designer, as shown in the image below:
PS 结果
该解决方案来源于此的 MSDN例如
这篇关于添加的TrackBar控制到ContextMenu的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文