Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a TrackBar in ToolStrip

I am trying to add a TrackBar in my ToolStrip. I have found this code somewhere on the net but I am not sure how to use it as it should be compiled maybe?

Code

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

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

Any tips will be appriciated!

like image 578
Saeid Yazdani Avatar asked Apr 13 '11 12:04

Saeid Yazdani


1 Answers

You can simply copy this code in your form source file. (You also need to import some extra stuff, using System.Windows.Forms.Design;).

Then you'll be able to see TraceBarItem in the designer when you try to add an element to your toolstrip.

To customize your TraceBar, add this to the constructor of the class you posted:

TrackBar tb = (TrackBar)this.Control;

You can set all the trackbar's properties using that tb object.

like image 193
Nejc Saje Avatar answered Oct 23 '22 12:10

Nejc Saje