Lodestone6 Lodestone6 -4 years ago 144
C# Question

Is there any way to do something like Slider.AutoToolTipPlacement in Winforms?

I'm wondering if there is any way to have the value of a slider displayed in tooltip when the thumb is moved on a slider in winforms? It seems to be doable in wpf (MSDN). Right now I'm just displaying it in a text box to the side, but I would like a more visually minimal way of doing it. Thanks

Answer Source

Assuming you are using a Trackbar and a Tooltip in your form, you could use the following code :

public partial class Form1 : Form
    public Form1()
        this.trackBar1.ValueChanged += trackBar1_ValueChanged;

    void trackBar1_ValueChanged(object sender, EventArgs e)
        // Force the ToolTip text to be displayed whether or not the form is active.
        toolTip1.ShowAlways = true;

        // Set up the ToolTip text for the Button and Checkbox.
        toolTip1.SetToolTip(this.trackBar1, trackBar1.Value.ToString());
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download