Adding a TrackBar Control to ContextMenu

Can I add a TrackBar control to ContextMenu? So when I right-click my ContextMenu will drop out and the TrackBar will appear as a menu item?

+3
source share
3 answers

If your context menu ContexMenuStrip, you can create an element 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...
}

Thanks to the attribute, ToolStripItemDesignerAvailabilityyou can even see an element in Forms Designer, as shown in the figure below:

alt text

PS
This solution comes from this MSDN example

+11
source

, . MenuItem, TrackBar

0

, , :

"System.Windows.Forms.ToolStripControlHost" .

, , , . , , .

0

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


All Articles