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

SelectAll

2 Answers 108 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Darryn
Top achievements
Rank 1
Darryn asked on 25 Jun 2012, 06:52 PM
I was hoping to implement SelectAll functionality when the user double clicks in the cell that is to the left of the first column and above the first row.

I tried using hittesting to detect when the user clicks there, but didn't have any luck since it wasn't coming up as a valid row or column. 

Is is possible to do this?

2 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 26 Jun 2012, 01:34 PM
Hello,

In order to detect the cell you double-clicked on, you can work direcly with MouseDoubleClick event. For example:

private void clubsGrid_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            var clickedElement = e.OriginalSource as FrameworkElement;
            if(clickedElement != null)
            {
                if(clickedElement.ParentOfType<GridViewCell>() != null)
                {
                    MessageBox.Show("You clicked on a cell");
                }
            }
        }

You could as well take a look at this online demo on the click events.

All the best,
Didie
the Telerik team

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

0
Darryn
Top achievements
Rank 1
answered on 26 Jun 2012, 02:19 PM
Since I only care about the cell in between the first column and the row indicator (which technically isnt a cell) I had to make some adjustments to the code. This looks like it works:

var clickedElement = e.OriginalSource as FrameworkElement;
if (clickedElement != null)
{
    if (clickedElement.ParentOfType<GridViewHeaderRow>() != null)
    {
        if (clickedElement.ParentOfType<DataCellsPresenter>() == null)
        {
            var dgv = e.Source as RadGridView;
            dgv.SelectAll();
        }                   
    }               
}
Tags
GridView
Asked by
Darryn
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Darryn
Top achievements
Rank 1
Share this question
or