The default tooltip that is displayed when the node text is truncated (as determined by the Override.TipStyleNode property) prevents the control from being scrolled using the mouse wheel. The default behaviour is to display this tooltip immediately on mouse enter so there isn't even a grace period where you can get to scroll the tree before the tooltip is displayed.I have managed to work around this, what we need to do is to get hold of the actual form that is used to display the tooltip, handle it's MouseWheel event and forward it to the tree control instead. The actual tooltip object used to display the tooltip is in fact a member of the UltraTree, it just isn't public. Get hold of this object using reflection, then the form is stored in the Control property on which we register the event. Then in the MouseWheel event we need to call OnMouseWheel on the tree, I'm using reflection again to do this to save me from having to inherit from UltraTree. The code looks like this:
public Form1() { InitializeComponent(); // Get the tooltip using reflection var toolTipGet = ultraTree1.GetType().GetProperty("ToolTip", BindingFlags.NonPublic | BindingFlags.Instance); ToolTip toolTip = (ToolTip)toolTipGet.GetValue(ultraTree1, null); // Control is the form used to display the tooltip and hence gets the mouse events toolTip.Control.MouseWheel += Owner_MouseWheel; } void Owner_MouseWheel(object sender, MouseEventArgs e) { // forward to the tree var omw = ultraTree1.GetType().GetMethod("OnMouseWheel", BindingFlags.NonPublic | BindingFlags.Instance); omw.Invoke(ultraTree1, new object[] { e }); }
I would like Infragistics to build this functionality into the Form the tooltip uses (ToolTipFormEx?).
Also in other forum posts people have asked how to customize the appearance of the tooltip (specifically the font as it defaults to sans serif) and the response has been to roll your own tooltip! There is a much easier way, just set the font on the same protected tooltip object. Note don't set it on the form (tooltip.Control) as some dodgy logic in ToolTip.OnFormDisposed throws an exception when your form is disposed)
toolTip.Font = ultraTree1.Font;
cheers
Martin
Oh... regarding the font... I'm pretty sure the tooltips use the same font as the node. If they don't do this by default, then I am sure they will if you set UseEditors to true on the Override.
It doesn't use it by default - in fact all I wanted is for the tooltip font to match the node font. However the UseEditor suggestion does indeed work so this is useful information for people.
Thanks Mike,
Martin,
I believe the UltraTree has to have focus before the mouse wheel will work with it. If you click into the control I think you will see that the wheel will work even if the tooltip is displayed. I am sending you a small sample application which you can use to demonstrate this. The sample contains an Infragistics UltraTree and a Microsoft TreeView and they both seem to work the same way. Look it over and let me know what you think.
Michael S.
Did the sample I posted here help you to sort out the issues you were having with the mouse wheel and the tooltips? Let me know if there is anything else I can help you with.
I am using 9.2 (with the latest hotfix), however your sample uses 10.3. So I guess that it has been fixed, although I can't test it as I don't have v10 - so I'll stick with my workaround. thx.
Martin.