简体   繁体   English

有什么办法可以在Winforms中执行Slider.AutoToolTipPlacement之类的操作吗?

[英]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.

相关问题 有没有办法在C#中做这样的事情? - Is there any way to do something like this in C#? c#我可以为“if”这样做吗? 或任何其他方式做这样的事情? - c# Can I do this for “if”? or any other way to doing something like this? 像任何比较文件软件一样,如何通过一个滑块控制Winforms中的两个列表 - How to control two lists in winforms though one single slider just like in any compare file software 有没有办法在Winforms中所有者绘制(或类似方式)MainMenu? - Is there a way to ownerdraw (or something similar) a MainMenu in Winforms? 有没有办法使用WinForms创建一个类似“Dock”的应用程序,能够打开其他窗口? - Is there any way to use WinForms to create a “dock”-like app that is able to open additional windows? 控制以显示在winforms中执行某些操作的步骤 - control to show steps to do something in winforms Winforms不允许调整大小 - Winforms do not allow any resizing 有没有办法完成像List这样的事情 <object> list =新列表 <int> ()在C#? - Is there any way to accomplish something like List<object> list = new List<int>() in C#? 如何将我的 Winforms 模块划分为插件之类的东西 - How to divide my Winforms modules into something like plugins .NET Winforms DataGridView - 任何嵌套方式? - .NET Winforms DataGridView - Any way to nest?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM