C # Show tooltip about disabled text field (form)

I am trying to get a tooltip to display in a disabled text field while mouse is clicked. I know, because the control is disabled, the following will not work:

private void textBox5_MouseHover(object sender, EventArgs e)
{
       // My tooltip display code here
}

How can I get a tooltip to display with the mouse with the control disabled?

Many thanks

+5
source share
2 answers

MouseHover will not work if control is disabled. Instead, you can check the Form MouseMove event if you are hovering a text field

    public Form1()
    {
        InitializeComponent();
        textBox1.Enabled = false;
        toolTip.InitialDelay = 0;
    }

    private ToolTip toolTip = new ToolTip();
    private bool isShown = false;

    private void Form1_MouseMove(object sender, MouseEventArgs e)
    {
        if(textBox1 == this.GetChildAtPoint(e.Location))
        {
            if(!isShown)
            {
                toolTip.Show("MyToolTip", this, e.Location);
                isShown = true;
            }
        }
        else
        {
            toolTip.Hide(textBox1);
            isShown = false;
        }
    }

enter image description here

+16
source

ToolTip . SetToolTip() .. , .

myToolTip.SetToolTip(myTextBox, "You just hovered over myTextBox!");
0

All Articles