简体   繁体   English

Telerik WPF GridView在GridView中获取GridView的SelectedItems

[英]Telerik WPF GridView get SelectedItems of GridView in a GridView

I have a Telerik WPF GridView which has a Gridview as HierarchyChildTemplate. 我有一个Telerik WPF GridView,其中有一个Gridview作为HierarchyChildTemplate。

When I expand one row in the upper hierarchy, I can select rows in the lower hierarchy. 当我在较高层次结构中展开一行时,可以在较低层次结构中选择行。 Now I want to click a button and on the button_click event I want to access the SelectedItems. 现在,我要单击一个按钮,并要在button_click事件上访问SelectedItems。 Does anyone know how to get there? 有人知道怎么去吗?

Thank you for the help. 感谢您的帮助。

EDIT 编辑

I got the solution for my problem: 我为我的问题找到了解决方案:

  1. Subscribe to the SelectionChanged event of the child GridView 订阅子GridView的SelectionChanged事件
  2. In the event handler the sender will be the current child GridView 在事件处理程序中,发送者将是当前子GridView
  3. Store actual SelectedItems of the child GridView in an instance variable 将子GridView的实际SelectedItems存储在实例变量中
  4. Use stored SelectedItems when needed 在需要时使用存储的SelectedItems

     private void SubGrid_SelectionChanged(object sender, SelectionChangeEventArgs e) { var subGrid = (RadGridView) sender; _subGridSelectedItems = subGrid.SelectedItems; } 

You can read the SelectedItems property of the child grid in the click handler of the button. 您可以在按钮的单击处理程序中读取子网格的SelectedItems属性。

If your child grid is named childGrid you can access the selected rows like this: 如果您的子网格名为childGrid,则可以像这样访问所选的行:

var selectedRows = childGrid.SelectedItems;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM