Search code examples
winformsdevexpressxtragridmousedownmouseup

Incorrect HitTest on resizing a DevExpress XtraGrid column


Custom sorting and column resize does not work.

Implemented custom sorting on MouseUp event handler however

if ( hitInfo.InColumnPanel && hitInfo.HitTest == GridHitTest.ColumnEdge)
{
   (e as DXMouseEventArgs).Handled = true;
    return;
}

does not work for the event.

Would like to be able to click on the column header to sort and resize by dragging column edge.


Solution

  • private void OnMouseDown(object sender, MouseEventArgs e)
    {
       GridHitInfo hitInfo = gridView1.CalcHitInfo(e.Location);
       if (hitInfo.HitTest == GridHitTest.ColumnEdge)
       {
          isEdgeClicked = true;
       }
    }
    
    private void OnMouseUp(object sender, System.Windows.Forms.MouseEventArgs e) 
    {
       if (isEdgeClicked)
       {   isEdgeClicked = false;
           return;
       }
       else 
       {
          (e as DXMouseEventArgs).Handled = true;
       }
    }