Reputation: 243
I have simple CTreeCtrl on my dialog. It has only two levels of depth, something like this:
Imagine that the user clicked on "Third" node so it becomes selected, then he pushing on the button that is also on the dialog and executes next code:
// m_tree is a dialog-based class member of CTreeCtrl type
HTREEITEM hItem = m_tree.GetSelectedItem();
if (hItem)
{
hItem = m_tree.GetNextSiblingItem(hItem);
if (hItem)
{
m_tree.SelectItem(hItem);
}
}
After that hItem, which label is "Fourth" in my sample, becomes visible at the bottom of tree control window:
How can I force tree control not to scroll down to selected item? I just want to select it and that's all.
Upvotes: 1
Views: 480
Reputation: 1917
You can try calling EnsureVisible on the previously selected item. This might flicker though, so you may try using SetRedraw(FASLE) before making the new selection and EnsureVisible.
Upvotes: 2