请问大家,如何将进度条TrackBar 放进Menu里面呢?<<帮助>>那行是MenuStrip,<<速度>>那行是ToolStrip,可是ToolStrip里面没有TrackBar 控件,只有
这样该如何实现呢?
In .NET there's a class named ToolStripControlHost which can be used to host custom controls or Windows Forms controls, in two ways:
Construct a ToolStripControlHost with a class that derives from Control. To fully access the hosted control and properties, you must cast the Control property back to the actual class it represents.
Extend ToolStripControlHost, and in the inherited class's default constructor, call the base class constructor passing a class that derives from Control. This option lets you wrap common control methods and properties for easy access in a ToolStrip.
The following sample demonstrates how to create a custom ToolStripTraceBarItem.
[ToolStripItemDesignerAvailability
(ToolStripItemDesignerAvailability.ToolStrip |
ToolStripItemDesignerAvailability.StatusStrip)]
public class ToolStripTraceBarItem : ToolStripControlHost
{
public ToolStripTraceBarItem()
: base(new TrackBar())
{
}
}
After compiling, you'll find a ToolStripTraceBarItem in the drop down of the ToolStrip, select it from the drop down you'll be able to add a TraceBar to the ToolStrip.
http://msdn.microsoft.com/en-us/library/system.windows.forms.toolstripcontrolhost.aspx
看中间那段代码就行了,新建这样一个Class, 然后编译一下,就可以插进去这个类了
嗯,这个功能实现了,但界面外观不好看。