Adding TrackBar to ToolStrip

I am trying to add a TrackBar to my ToolStrip. I found this code somewhere on the net, but I'm not sure how to use it since it needs to be compiled, maybe?

the code

/// <summary> /// Adds trackbar to toolstrip stuff /// </summary> [ ToolStripItemDesignerAvailability (ToolStripItemDesignerAvailability.ToolStrip | ToolStripItemDesignerAvailability.StatusStrip) ] public class ToolStripTraceBarItem : ToolStripControlHost { public ToolStripTraceBarItem(): base(new TrackBar()) { } } 

Any clues will be announced!

+6
source share
1 answer

You can simply copy this code to the source file of the form. (You also need to import additional materials using System.Windows.Forms.Design; ).

You can then see TraceBarItem in the designer when you try to add an item to your toolbar.

To configure TraceBar, add it to the constructor of the class that you placed:

TrackBar tb = (TrackBar)this.Control;

You can set all the properties of the trackbar using this tb object.

+5
source

Source: https://habr.com/ru/post/885813/


All Articles