none
Insert trackbar into C# forms toolbar RRS feed

  • Question

  • Ten years ago, someone asked "How to insert trackbar into toolstrip bar"

    Zhi-Xin Ye from Microsoft Forum Support Team suggested inserting the below code, and then said "After compiling, you'll find a ToolStripTraceBarItem in the drop down of the ToolStrip, select it from the drop down you'll be able to add a TraceBar to the ToolStrip."

    Except that doesn't happen. I've compiled the below, and VS2012 toolbar drop down shows all the usual items, including ProgressBar, but no ToolStripTraceBarItem.

    What else needs to be done to make a trackbar or slider available in a C# toolbar?

    [ToolStripItemDesignerAvailability    (ToolStripItemDesignerAvailability.ToolStrip |    ToolStripItemDesignerAvailability.StatusStrip)]
    public class ToolStripTraceBarItem : ToolStripControlHost
    {
        public ToolStripTraceBarItem() : base(new TrackBar())
        {
        }
    }
    

    Thursday, January 18, 2018 6:25 PM

All replies

  • In Visual Studio 2017, TrackBar can be found in the “All Windows Forms” area of Toolbox. You can also right-click the opened Toolbox, then “Choose Items…”, where you can find and enable the TrackBar control. Check if this can be done in your version.

    Friday, January 19, 2018 6:03 AM
  • Hi Rrank Badami,

    Thank you for posting here.

    For your question, I try to use the code in winform with Visual Studio 2012. It works well.

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.Windows.Forms.Design;
    
    namespace WindowsFormsApplication
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
    
            }
        }
        [ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.ToolStrip | ToolStripItemDesignerAvailability.StatusStrip)]
    
        public class ToolStripTraceBarItem : ToolStripControlHost
        {
    
            public ToolStripTraceBarItem()
    
                : base(new TrackBar())
            {
    
    
    
            }
    
        }
    }
    

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, January 19, 2018 6:10 AM
    Moderator
  • Hi Frank Badami,

    Any update? Have you solved your problem?

    If you solved your problem, please mark the useful reply as answer. This will make answer searching in the forum and be beneficial to community members as well.

    If you have something else about this issue, please feel free to contact us.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Saturday, January 27, 2018 2:35 PM
    Moderator