Row Double Click

6 posts, 0 answers
  1. Kevin Meyer
    Kevin Meyer avatar
    36 posts
    Member since:
    Dec 2007

    Posted 17 Sep 2008 Link to this post

    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?
  2. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 18 Sep 2008 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. erwin
    erwin avatar
    358 posts
    Member since:
    Dec 2006

    Posted 19 Sep 2008 Link to this post


    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

  5. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 19 Sep 2008 Link to this post

    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.
  6. Richard
    Richard avatar
    32 posts
    Member since:
    Aug 2010

    Posted 15 Sep 2011 Link to this post

    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
  7. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 16 Sep 2011 Link to this post

    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 >>

Back to Top
UI for WinForms is Visual Studio 2017 Ready