This is a migrated thread and some comments may be shown as answers.

MouseRightButtonUp event: how to detect header or cell ?

2 Answers 111 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Doots
Top achievements
Rank 1
Doots asked on 11 Jun 2012, 05:41 PM
Hi,

I'm catching the MouseRightButtonUp event when a user click on the gridview with the right button. It works as I want, but i would like to be able to determine if the user clicked a header or a cell in the gridview. Is it possible to detect it in this event ? Thanks a lot for your help!

Doots

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimitrina
Telerik team
answered on 12 Jun 2012, 06:35 AM
Hello,

 You could check what the e.OriginalSource of the MouseButtonEventArgs is.

If you have clicked on a TextBlock, then you can check if the Parent of the clicked element is a GridViewCell or a GridViewHeaderCell.
For example something similar to:

private void clubsGrid_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
{
            var s = e.OriginalSource as FrameworkElement;
            if (s.ParentOfType<GridViewCell>() != null)
            { ...
            }
            else if (s.ParentOfType<GridViewHeaderCell>() != null)
            { ...
            }
 }

I hope this helps.

All the best,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Doots
Top achievements
Rank 1
answered on 12 Jun 2012, 07:26 AM
This is exactely what I was looking for ! Thanks for your help :)

Regards,
Doots
Tags
GridView
Asked by
Doots
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Doots
Top achievements
Rank 1
Share this question
or