[英]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? 我想知道当拇指在Winforms中的滑块上移动时,是否有任何方法可以在工具提示中显示滑块的值? It seems to be doable in wpf ( MSDN ).
在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
谢谢
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()
{
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());
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.