How to handle row double click in GridView?

12,251

Basically you should Handle GridView.DoubleClick

private void УчасткиGridControlDoubleClick(object sender, EventArgs e) {

GridView view = (GridView)sender;

Point pt = view.GridControl.PointToClient(Control.MousePosition);

DoRowDoubleClick(view, pt);

}

   private static void DoRowDoubleClick(GridView view, Point pt) {

GridHitInfo info = view.CalcHitInfo(pt);

if(info.InRow || info.InRowCell) {

    string colCaption = info.Column == null ? "N/A" : info.Column.GetCaption();

    MessageBox.Show(string.Format("DoubleClick on row: {0}, column: {1}.", info.RowHandle, colCaption));

}

For more please refer to Devexpress Double Click

Note: This code works only when your grid is not editable

Share:
12,251
Kliver Max
Author by

Kliver Max

Updated on June 14, 2022

Comments

  • Kliver Max
    Kliver Max almost 2 years

    I have a DevExpress GridControl. I want to handle a row doubleclicks with it. I do:

            private void УчасткиGridControlDoubleClick(object sender, EventArgs e)
        {
            GridControl grid = sender as GridControl;
            DXMouseEventArgs args = e as DXMouseEventArgs;
            var hitInfo = grid.Views[0].CalcHitInfo(args.Location) as GridHitInfo;
    
            MessageBox.Show(hitInfo.HitTest.ToString());
        }
    

    But i get message only if click on Row Indicator or Column Header.
    How to handle clicks on row's cells?