Search code examples
c#winformsdevexpressxtragrid

How to perform an action on double click for GridControl


I have a GridControl.

    private void gridControl1_DoubleClick(object sender, EventArgs e)
    {
        GridControl grid = sender as GridControl;            
        DXMouseEventArgs args = e as DXMouseEventArgs;
        BaseHitInfo hitInfo = grid.Views[0].CalcHitInfo(args.Location);
        MessageBox.Show("Hello World");
    }

How can I display MessageBox.Show("Hello World") only if the user double clicks on row data? The code above shows hello world even if the user double clicks on whitespace.


Solution

  • Cast hitInfo to GridHitInfo and check the HitTest property.