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

Row Double Click

7 Answers 1858 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kevin Meyer
Top achievements
Rank 1
Kevin Meyer asked on 17 Sep 2008, 10:33 PM
Is there a way to differential data row double-clicks from double-clicks in the header or scroll bar.  RadGridView::DoubleClick seems to fire when anything is double clicked, and the sender is always the grid, not the specific element.

Looking at MouseDoubleClick, I think I might be able to use the event's X and Y to get the child control at that position and check to see if it's a data row.  Are there other options?

7 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 18 Sep 2008, 03:47 PM
Hello Kevin,

Thank you for this question.

I would suggest using the CellDoubleClick event. This event is fired only when a cell element is hovered. To use the event effectively you should set the grid to read only mode by setting the ReadOnly property to true. When processing the CellDoubleClick event, you can get the current cell through the CurrentCell property of RadGridView. Consider the code below:

void radGridView1_CellDoubleClick(object sender, GridViewCellEventArgs e) 
    object value = this.radGridView1.CurrentCell.Value; 


You can get the element that is currently hovered by using the GetElementAtPoint method. Take a look at the following code snippet:

void radGridView1_DoubleClick(object sender, EventArgs e) 
    Point pt = this.radGridView1.PointToClient(Control.MousePosition); 
    GridCellElement cell =  this.radGridView1.ElementTree.GetElementAtPoint(pt) as GridCellElement; 
    if (cell != null
    { 
        //... 
    } 


I hope this helps. Please contact me if you need further assistance.

Kind regards,
Jack
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
erwin
Top achievements
Rank 1
Veteran
Iron
answered on 19 Sep 2008, 10:35 AM

To act only on double clicks on data rows, I use the following code in the CellDoubleClick handler:

// make sure we do have a valid current row
if(_grid.CurrentRow==null)
{
    return;
}

// make sure we have a data row
if(_grid.CurrentRow.RowElementType!=typeof(GridDataRowElement)
{
    return;
}

// process the event from here on

0
Jack
Telerik team
answered on 19 Sep 2008, 04:15 PM
Hi erwin,

You are correct, thank you for the additional info. Another way of doing this is to check if the CurrentRow is an instance of GridViewDataRowInfo.

 
Best wishes,
Jack
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Richard
Top achievements
Rank 1
answered on 16 Sep 2011, 03:44 AM
Thanks, this did help me:
The code below determines whether the current row is a data row (and whether the double click event should be processed).

Private Sub RadGrid1_CellDoubleClick(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.GridViewCellEventArgs) Handles RadGrid1.CellDoubleClick
 
   Dim bProcessDoubleClick As Boolean = False
 
   If RadGrid1.CurrentRow IsNot Nothing Then
      If TryCast(RadGrid1.CurrentRow, GridViewDataRowInfo) IsNot Nothing Then
         bProcessDoubleClick = True
      End If
   End If
 
   If bProcessDoubleClick Then
      'Logic
   End If
 
End Sub
0
Jack
Telerik team
answered on 16 Sep 2011, 02:40 PM
Hello Richard, thank you for sharing your code with the community. In case you have questions, do not hesitate to contact us.
 
All the best,
Jack
the Telerik team

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

0
Aseman
Top achievements
Rank 1
Veteran
answered on 17 Sep 2019, 08:38 AM

thank you so much kevin 

I don`t know what`s exactly happening ,this event Is SO SLOWWWW

can you help me Pls?

0
Nadya | Tech Support Engineer
Telerik team
answered on 18 Sep 2019, 11:25 AM
Hello Aseman,

I tested the provided solutions, and it did not seem to be slow at my side. Could you please specify what is the exact behavior that you want to achieve. It would be greatly appreciated if you can provide a sample project demonstrating the undesired behavior that you are facing. Thus, we would be able to think about a suitable solution and assist you further. Thank you in advance.

Should you have further questions please let me know. 

Regards,
Nadya
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Kevin Meyer
Top achievements
Rank 1
Answers by
Jack
Telerik team
erwin
Top achievements
Rank 1
Veteran
Iron
Richard
Top achievements
Rank 1
Aseman
Top achievements
Rank 1
Veteran
Nadya | Tech Support Engineer
Telerik team
Share this question
or