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

RadGridView double click event

3 Answers 371 Views
GridView
This is a migrated thread and some comments may be shown as answers.
ronald
Top achievements
Rank 1
ronald asked on 04 Feb 2011, 07:55 AM
Hi,
I need to capture which one the user clicked on mousedoubleclick event of radgridview..

I need to differentiate if the user clicked on the cell or on the border of the grid.. How can i achive this?

thanks

3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 04 Feb 2011, 02:06 PM
Hello ronald,

You may verify the type of the original source:

private void clubsGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var originalSource = e.OriginalSource as FrameworkElement;
            if (originalSource is TextBlock)
            {
                MessageBox.Show("The original source is TextBlock");
            }
            else if (originalSource is Border)
            {
                MessageBox.Show("The original source is Border");
            }
            else
            {
                MessageBox.Show("The original source is: " + e.OriginalSource);
            }
        }
 

Regards,
Maya
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
ronald
Top achievements
Rank 1
answered on 04 Feb 2011, 02:08 PM
if you double click on the line between cells it will detect as a border too.. how can i avoid this?
0
Maya
Telerik team
answered on 04 Feb 2011, 02:23 PM
Hi ronald,

You may use the ParentOfType<T> extension method and verify whether it is a GridViewCell or not:

private void playersGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var originalSource = e.OriginalSource as FrameworkElement;
            if (originalSource is Border)
            {
                if ((originalSource as Border).ParentOfType<GridViewCell>() != null)
                {
                    MessageBox.Show("You have clicked on a Border of a GridViewCell");
                }
                else
                {
                    MessageBox.Show("The original source is Border");
                }
            }
        }
 

Greetings,
Maya
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
GridView
Asked by
ronald
Top achievements
Rank 1
Answers by
Maya
Telerik team
ronald
Top achievements
Rank 1
Share this question
or