用于WPF的Telerik UI免费下载30天试用版

分组活动

当RadGridView中的数据是从UI分组

有两个事件被引发,当用户展开/折叠组行在RadGridView。

下面的代码片段显示了如何订阅这些事件:

clubsGrid。分组+= clubsGrid_Grouping; clubsGrid.Grouped += clubsGrid_Grouped; clubsGrid.GroupRowIsExpandedChanged += clubsGrid_GroupRowIsExpandedChanged; clubsGrid.GroupRowIsExpandedChanging += clubsGrid_GroupRowIsExpandedChanging;
AddHandler clubsGrid。分组, AddressOf clubsGrid_Grouping AddHandler clubsGrid.Grouped, AddressOf clubsGrid_Grouped AddHandler clubsGrid.GroupRowIsExpandedChanged, AddressOf clubsGrid_GroupRowIsExpandedChanged AddHandler clubsGrid.GroupRowIsExpandedChanging, AddressOf clubsGrid_GroupRowIsExpandedChanging

分组活动

通过Telerik.Windows.Controls.GridViewGroupingEventArgs分组事件您可以获得:

  • GroupDescriptor它定义了要添加的组。它的类型是IGroupDescriptor,你可以将它强制转换为ColumnGroupDescriptor如果分组是从UI或到完成的GroupDescriptor如果您向gridview的GroupDescriptors集合添加了GroupDescriptor(这是传统的方法)。从ColumnGroupDescriptor您可以访问:

  • -执行组的列

  • SortDirection-上升或下降

  • DisplayContent-显示内容

  • 指数的描述符GroupDescriptors集合

  • 行动在…上执行GroupDescriptor。这些行动可以是:

  • 的地方-将组描述符添加到GroupDescriptors集合中(按列分组的用户)。

  • 移动-组描述符被移动到GroupDescriptors集合中的另一个索引(用户重新排列了分组列)。

  • 删除-组描述符从GroupDescriptors集合中移除(用户取消了列的分组)

  • 排序-用户通过单击分组面板中的矩形对分组列进行了排序

  • 取消—如果设置为“True”,则不进行分组。

例如,您可以使用分组事件,以防止用户添加多个组。

private void clubsGrid_Grouping(对象发送方,GridViewGroupingEventArgs e) {if (e.g action == GroupingEventAction.)Place && e.Index > 0) {e.Cancel = true;}}
Private Sub clubsGrid_Grouping(sender As Object, e As GridViewGroupingEventArgs)Place AndAlso e.Index > 0 Then e.Cancel = True End If End Sub

分组活动

分组事件在数据已分组时引发。对组执行的所有其他操作(例如排序或删除它)也将引发带有相关GridViewGroupedEventArgs的事件。行动

通过GridViewGroupedEventArgs参数可以得到:

  • GroupDescriptor这已经被操纵了。它的类型是IGroupDescriptor,你可以将它强制转换为ColumnGroupDescriptor如果分组是从UI或到完成的GroupDescriptor如果您向gridview的GroupDescriptors集合添加了GroupDescriptor(这是传统的方法)。从ColumnGroupDescriptor您可以访问:

  • -执行组的列

  • SortDirection-上升或下降

  • DisplayContent -显示内容

  • 行动在上面执行。这些行动可以是:

  • 的地方-将组描述符添加到GroupDescriptors集合中(按列分组的用户)。

  • 移动-组描述符被移动到GroupDescriptors集合中的另一个索引(用户重新排列了分组列)。

  • 删除-组描述符从GroupDescriptors集合中移除(用户取消了列的分组)

  • 排序-用户通过单击分组面板中的矩形对分组列进行了排序

例如,您可以使用分组事件获取分组的列。

private void clubsGrid_Grouped(对象发送方,GridViewGroupedEventArgs e) {GridViewDataColumn column = ((Telerik.Windows.Controls.GridView.ColumnGroupDescriptor)(e.g groupdescriptor))。列作为gridviewdatacolumcolumn;对话框。Show(" GridView按列分组:" + column. header . tostring ());}
Private Sub clubsGrid_Grouped(sender As Object, e As GridViewGroupedEventArgs) Dim column As GridViewDataColumn = TryCast(DirectCast(e。GroupDescriptor Telerik.Windows.Controls.GridView.ColumnGroupDescriptor)。列,gridviewdatacolumcolumn)。Show("The GridView was grouped by column: " + column. header . tostring ()) End Sub

GroupRowIsExpandedChanging事件

GroupRowIsExpandedChanging事件在用户展开组行时引发。

通过GroupRowCancelEventArgs你可以争论取消扩展组行的动作。你也可以得到GridViewGroupRow (e.Row)你刚刚扩张了。

例如,您可以使用GroupRowIsExpandedChanging像这样的事件。

private void clubsgrid_grouprowisexpdedchanged(对象发送方,telerik . windows . controls . gridview . grouprocanceleventargs e) {e. cancel = true;}
Private Sub clubsgrid_grouprowisexpdedchanging (sender As Object, e As Telerik.Windows.Controls.GridView.GroupRowCancelEventArgs) e. cancel = True结束Sub

GroupRowIsExpandedChanged事件

GroupRowIsExpandedChanged事件在用户展开组行时引发。

通过GroupRowEventArgs你可以得到GridViewGroupRow (e.Row)你刚刚扩张了。

例如,您可以使用GroupRowIsExpandedChanged事件获取展开的组行,并为其设置不同的背景。

private void clubsgrid_grouprowisexpdedchanged(对象发送方,Telerik.Windows.Controls.GridView.GroupRowEventArgs e) {GridViewGroupRow expdedgroup = e. row作为GridViewGroupRow;if (expdedgroup . isexpanded) {Background = new SolidColorBrush(Colors.Red);} else {expandedGroup.}Background = new SolidColorBrush(Colors.Green);}}
Private Sub clubsgrid_grouprowisexpdedchanged (sender As Object, e As Telerik.Windows.Controls.GridView.GroupRowEventArgs) Dim expandedGroup As GridViewGroupRow = TryCast(e。Row, GridViewGroupRow)如果扩展组。IsExpanded然后是expandedGroup。Background = New SolidColorBrush(Colors.Red)Background = New SolidColorBrush(Colors.Green) End If End Sub

另请参阅

在本文中
Baidu
map