有什么办法可以像Winforms中的Slider.AutoToolTipPlacement这样做吗?
问题描述:
我想知道是否有任何方式来将滑块的值显示在工具提示中,当拇指在winforms中的滑块上移动时?这似乎是可行的wpf(MSDN)。现在我只是在文本框中显示它,但是我想要一个更直观的方式来做到这一点。由于有什么办法可以像Winforms中的Slider.AutoToolTipPlacement这样做吗?
答
假设你使用的是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());
}
}
的可能重复[我怎样才能显示出一个跟踪条中的WinForms价值的工具提示] (http://stackoverflow.com/questions/892369/how-can-i-display-a-tooltip-showing-the-value-of-a-trackbar-in-winforms) – lokusking