Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a TrackBar control to a ContextMenu

Is it possible to add a TrackBar control to a ContextMenu? So when I right click, my ContextMenu will drop down and a TrackBar will appear as a menu item?

like image 775
Icemanind Avatar asked Dec 13 '22 17:12

Icemanind


1 Answers

If your context menu is a ContexMenuStrip, you can create an item in 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 ToolStripItemDesignerAvailability attribute, you can even see the item in the Forms Designer, as shown in the image below:

alt text

P.S.
This solution comes from this MSDN example

like image 164
digEmAll Avatar answered Dec 26 '22 15:12

digEmAll