Hi,
I've got a form that contains an UltraTree where I build nodes on the fly. Also on the form is an UltraStatusBar with one panel set to AutoStatusText.
Is there a way to set the StatusBar text so that it displays when the mouse hovers one of the nodes? I apparently can't pass the Node into the SetStatusBarText method because it's the incorrect type.
I tried adding an UltraFormattedLinkLabel as the Nodes label. I was able to call SetStatusBarText and pass in the LinkLabel and text, but the text doesn't display when over the node.
Thanks,
JL
Hi JL,
You can just pass in the tree as the Component parameter to SetStatusBarText. Control derives from Component, so you can use any Control for this. My guess is that the StatusBar only uses the component to tell when the mouse has moved outside of it, so it knows when to clear the message. So in this case, the text will show up when you move over a node and will change if you move over another node, but it won't disppear until the mouse leaves the tree.
You could, of course, fix this by blanking it out yourself.
private void ultraTree1_MouseMove(object sender, MouseEventArgs e) { UltraTree tree = (UltraTree)sender; UltraTreeNode node = tree.GetNodeFromPoint(e.X, e.Y); if (node != null) this.ultraStatusBar1.SetStatusBarText(tree, node.Text); else this.ultraStatusBar1.SetStatusBarText(tree, null); }
Hi Mike,
I tried your example, but unfortunately, the text that displays in the status bar is the last node that was processed. If I'm building a tree with 10 nodes, and I call SetStatusBarText as the nodes get created, passing in the tree, the last one in wins. No matter where the mouse is in the tree, the same text is displayed. It's essentially setting the text for the tree object itself.
Unless I'm doing something incorrectly, if there's not a way to pass a reference to a node to SetStatusBartext, I'll just use your example above using the MouseMove event.
Thanks!
Ok, I misunderstood.
I'll add the MouseMove event and set the text in there. Should work fine. I can get to the text I want easily enough.
Thanks.
You can't set the StatusText when the nodes are created, you have to do is at the mouse moves. The StatusText applies to the whole tree control, so you have to change the text for the tree control depending on the current location of the mouse.
I'm using the text of the node in my example, but if you want to use different text, then perhaps you can store the text you want in the Tag property of the node and then use that in MouseMove.