I would like to enable drag&drop support between grid column headers in order to implement a copy functionality for values from one column to another. I would like to use this instead of moving columns.
The existing drag&drop functionality seems to be centered on dragging records and I only found proposed solutions for column headers as drop target (e.g. Q582763).
How can I start drag operations from column headers?
To implement your custom logic for column dragging, disable GridControl's Drag&Drop by setting the TableView.AllowColumnMoving property to false and use the system Drag&Drop mechanism. For this, create an implicit style for the GridColumnHeader element and subscribe to the PreviewMouseDown and Drop events and set AllowDrop to true:
<Style TargetType="dxg:GridColumnHeader"> <Setter Property="AllowDrop" Value="True"/> <EventSetter Event="PreviewMouseDown" Handler="GridColumnHeader_PreviewMouseDown"/> <EventSetter Event="Drop" Handler="GridColumnHeader_Drop"/> </Style>
I have attached a simple example to illustrate the main idea of this approach. Please take a moment to review it and let us know if you need further assistance.