You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|2024.3.924|RadGridView for WinForms|[Nadya Karaivanova](https://www.telerik.com/blogs/author/nadya-karaivanova)|
22
17
23
18
## Description
24
19
25
-
When working with pinned columns in RadGridView, I want to prevent the user from dragging unpinned columns over or between the pinned columns. This issue arises when the first two columns are pinned, but an unpinned column can still be moved to the leftmost position or between pinned columns, effectively increasing the number of pinned columns.
26
-
27
-
This KB article also answers the following questions:
28
-
- How can I restrict column reordering in RadGridView with pinned columns?
29
-
- Is it possible to disable dragging columns over pinned columns in RadGridView for WinForms?
30
-
- What method can prevent a column from being moved over pinned columns in RadGridView?
20
+
When working with pinned columns in RadGridView, the client may want to prevent dragging unpinned columns over or between the pinned columns. Currently unpinned column can be moved to the leftmost position or between pinned columns, effectively increasing the number of pinned columns.
31
21
32
22
## Solution
33
23
34
24
To achieve the desired behavior, leverage the [RadDragDropService](https://docs.telerik.com/devtools/winforms/controls/gridview/drag-and-drop/radgridviewdragdropservice) of RadGridView, which handles the drag-and-drop operations. By handling the `PreviewDragOver` event, you can prevent a column from being dropped over a pinned column.
35
25
36
26
Follow these steps to implement the solution:
37
27
38
-
1. Access the `RadDragDropService` from your `RadGridView` instance.
39
-
2. Subscribe to the `PreviewDragOver` event of the `RadDragDropService`.
40
-
3. In the event handler, check if the target of the drag operation is a pinned column. If so, set `e.CanDrop` to `false` to prevent the drop.
By implementing this solution, you ensure that users cannot drag unpinned columns over or between pinned columns, maintaining the integrity of your column layout in RadGridView.
0 commit comments