How to reposition ToolTip in TreeView?

When using tooltips to display a detailed description of TreeNode, a tooltip is drawn at the top of the node, as if it were ending the text of the node. In addition, if the text is long, a tooltip is positioned so that the text extends beyond the screen .

But I need a tooltip that displays right below the mouse pointer, and not on top of the TreeNode.

Any ideas how to do this?


Show, don't say:

Like this:

how it is

How i want:

how i want

+3
source share
3 answers

I did not find the answer I was looking for, but somehow I did it the way I wanted.

I used to try to set up the prompt as follows:

    private void treeView1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
    {
        TreeNode node = treeView1.GetNodeAt(e.X, e.Y);
        if (node != null)
        {
                string text = GetNodeTooltip(node);
                string currentText = toolTip1.GetToolTip(treeView1);

                if (text.Equals(currentText) == false)
                {
                    toolTip1.SetToolTip(treeView1, text);
                }
            }
            else
            {
                toolTip1.SetToolTip(tree, string.Empty);
            }
        }
        else
        {
            toolTip1.SetToolTip(tree, string.Empty);
        }
    }

treeView1.ShowNodeToolTips=true, node, TreeNode.ToolTipText .

+8
private ToolTip toolTipController = new ToolTip() { UseFading = false,UseAnimation = false};

protected override void OnMouseMove(MouseEventArgs e)
{
    var node = GetNodeAt(e.X, e.Y);
    if (node != null)
    {
        var text = node.Text;

        if (!text.Equals(toolTipController.GetToolTip(this)))
        {
            toolTipController.Show(text, this, e.Location, 2000);
        }
    }
    else
    {
        toolTipController.RemoveAll();
    }
}
+3

MouseOverEventHandler TreeView. MouseOverEventHandler node, , ToolTip. , , .

StatusStrip - .

Update:

, . ToolTip.Show, :

public void Show(
    string text,
    IWin32Window window,
    int x,
    int y,
    int duration
)

, x y.

+2

Source: https://habr.com/ru/post/1697816/


All Articles