2017-02-28 96 views
0

我想知道是否有任何方式來將滑塊的值顯示在工具提示中,當拇指在winforms中的滑塊上移動時?這似乎是可行的wpf(MSDN)。現在我只是在文本框中顯示它,但是我想要一個更直觀的方式來做到這一點。由於有什麼辦法可以像Winforms中的Slider.AutoToolTipPlacement這樣做嗎?

+0

的可能重複[我怎樣才能顯示出一個跟蹤條中的WinForms價值的工具提示] (http://stackoverflow.com/questions/892369/how-can-i-display-a-tooltip-showing-the-value-of-a-trackbar-in-winforms) – lokusking

回答

1

假設你使用的是Trackbar,並在你的形式Tooltip,你可以使用下面的代碼:

public partial class Form1 : Form 
{ 
    public Form1() 
    { 
     InitializeComponent(); 
     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()); 
    } 
} 
相關問題