【问题标题】:Adding a TrackBar in ToolStrip在 ToolStrip 中添加 TrackBar
【发布时间】:2011-04-13 12:25:45
【问题描述】:

我正在尝试在我的 ToolStrip 中添加一个 TrackBar。我在网上的某个地方找到了这段代码,但我不确定如何使用它,因为它可能应该被编译?

代码

    /// <summary>
    /// Adds trackbar to toolstrip stuff
    /// </summary>
    [
    ToolStripItemDesignerAvailability
        (ToolStripItemDesignerAvailability.ToolStrip | ToolStripItemDesignerAvailability.StatusStrip)
    ]

    public class ToolStripTraceBarItem : ToolStripControlHost
    {
        public ToolStripTraceBarItem(): base(new TrackBar())
        {
        }
    }

任何提示都会被应用!

【问题讨论】:

    标签: c# toolstrip trackbar toolstripcontrolhost


    【解决方案1】:

    您可以简单地将这段代码复制到您的表单源文件中。 (你还需要导入一些额外的东西,using System.Windows.Forms.Design;)。

    然后,当您尝试将元素添加到工具条时,您将能够在设计器中看到 TraceBarItem

    要自定义您的 TraceBar,请将其添加到您发布的类的构造函数中:

    TrackBar tb = (TrackBar)this.Control;

    您可以使用 tb 对象设置所有轨迹栏的属性。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多