views:

377

answers:

2

Ok, this is a weird one.

The expected behaviour for a TreeView control is that, if ShowNodeToolTips is set to false, then, when a label for a tree node exceeds the width of the control (or, more accurately, it's right hand edge is past the right hand edge of the client area), then a tooltip is shown above the node showing the full item's text.

I'd like to disable that, because the above semantic doesn't always work, depending on what the treeview is contained within. So I have rolled my own, and got the tooltips to work (and line up better than the default one!) - but I would like to be able to disable the 'default' behaviour for situations where it would work natively.

So, can anyone point me in the right direction as to which message to post to the TreeView in order to disable that behaviour? I have looked at the windows control reference, but couldn't find anything that looked like it might be the one.

A: 

Sorry, but found this which doesn't help much... http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=337872

As a rather painful workaround, the only suggestion I have is to always set the Text to be empty to suppress any tooltips, use the TreeNode.Tag property to store the actual text of the node that you want to display, and owner-draw that text yourself.

A: 

Try this:

private const int TVS_NOTOOLTIPS = 0x80;

protected override System.Windows.Forms.CreateParams CreateParams
{
    get
    {
        CreateParams p = base.CreateParams;
        p.Style = p.Style | TVS_NOTOOLTIPS;
        return p;
    }
}
arbiter