Wednesday 10 December 2014


Share/Bookmark

Introduction


In this post, we will find out how to find the group, if grouping is applied on the radgridview, in which the event occurred. Or how to find if the row clicked is group row or not.

If you have subscribed to the mouse click event properly, you will get call to the delegate which is registered to the click event. You can refer to this post for proper subscription of mouse click event.

Now if you are getting calls to the delegate, then it is easy to find the row in which the event occurred, you can refer to this post to find out how you can achieve this.

Now to find out how to find the group in which this event occurred, you have to do something like this as shown below.

How to achieve this?

private void GridViewRowMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
   var senderElm = e.OriginalSource as FrameworkElement;
   var currentRow = senderElm.ParentOfType<GridViewRow>();
   var parentGroup = senderElm.ParentOfType<GridViewGroupRow>();

   if (currentRow == null && parentGroup != null)
    {
       // clicked on grouped row.
    }

   if (currentRow != null)
    {
      // clicked on a row.
    }
}
Categories:

0 comments:

Post a Comment

Dear reader, Your comment is always appreciated. I will reply to your queries as soon as possible.

1. Make sure to click on the Subscribe By Email link to be notified of follow up comments and replies. Or you can use Subscribe to: Post Comments (Atom) link.
2. Only English comments shall be approved.
3. Please make your comments self-explanatory. Comment in such a way that it explains the comment so that a counter question can be avoided and can be replied with proper answer on the first go.