如何将treelistcontrol滚动到选中的项?

时间:2022-03-29 10:31:08

is it possible to scroll the treelistcontrol to the selected item. so that selected items are always in view. I am programmatically selecting nodes using the call to SelectItem(nodeToSelect) by extending the treelistcontrol. A code snippet or a sample would be very helpful.

是否可以将treelistcontrol滚动到所选项。所以所选的项目总是可见的。通过扩展treelistcontrol,我使用对SelectItem(nodeToSelect)的调用以编程方式选择节点。代码片段或示例将非常有用。

1 个解决方案

#1


0  

You should use BringIntoView method.

您应该使用bringinto视图方法。

More documentation on this on devexpress:http://documentation.devexpress.com/#wpf/DevExpressXpfGridTreeListControlMembersTopicAll

在devexpress上了解更多相关文档:http://document.devexpress.com/ #wpf/DevExpressXpfGridTreeListControlMembersTopicAll

Also msdn information: http://msdn.microsoft.com/en-us/library/ms598110.aspx

还msdn信息:http://msdn.microsoft.com/en-us/library/ms598110.aspx

private void OnTreeViewItemSelected(object sender, RoutedEventArgs e)
{ 
  TreeViewItem item = e.OriginalSource as TreeViewItem;
  if (item != null)
   {        
    item.BringIntoView();
   }
}

#1


0  

You should use BringIntoView method.

您应该使用bringinto视图方法。

More documentation on this on devexpress:http://documentation.devexpress.com/#wpf/DevExpressXpfGridTreeListControlMembersTopicAll

在devexpress上了解更多相关文档:http://document.devexpress.com/ #wpf/DevExpressXpfGridTreeListControlMembersTopicAll

Also msdn information: http://msdn.microsoft.com/en-us/library/ms598110.aspx

还msdn信息:http://msdn.microsoft.com/en-us/library/ms598110.aspx

private void OnTreeViewItemSelected(object sender, RoutedEventArgs e)
{ 
  TreeViewItem item = e.OriginalSource as TreeViewItem;
  if (item != null)
   {        
    item.BringIntoView();
   }
}