开发者

How do I make a Control follow its parent in a scrolling TreeView?

开发者 https://www.devze.com 2023-01-08 18:35 出处:网络
I\'ve got a TreeView with a bunch of child nodes in it, all of which have child nodes of their own. A user asked me to provide auto-completion when editing any of the \"grandchild\" TreeNodes, so I h

I've got a TreeView with a bunch of child nodes in it, all of which have child nodes of their own.

A user asked me to provide auto-completion when editing any of the "grandchild" TreeNodes, so I had to implement a floating TextBox that sits directly over the TreeNode.

Problem is, if the user scrolls the TreeView with her mid开发者_StackOverflow社区dle mouse button while editing the TextBox, she sees the TreeView scroll while the TextBox stays put. This, despite the fact that I have parented the TextBox to the TreeView.

So, what property or event of the TreeView can I access to make the TextBox follow all the other nodes of the TreeView when the user scrolls it?

Note: I am not using WPF. (Normally I would, but I'm modifying a pre-exisitng project.)


It might be easiest to derive from TreeView and override the OnMouseWheel function. There you can either hide the TextBox or move it to keep up with your moving TreeNode. This article does something similar to what you're trying to do but with a DropDown. It hides the control in OnMouseWheel.

0

精彩评论

暂无评论...
验证码 换一张
取 消