I have AllowColumnReorder off on my grid. However, it still allows the user to drag columns. They can't be dropped anywhere, but the client is finding this distracting. They don't want the user to be able to drag a column accidentally and see the circle with the line through it.
Is there a way to disable dragging of the columns?
Is there a way to disable dragging of the columns?
4 Answers, 1 is accepted
0

Kyle
Top achievements
Rank 1
answered on 13 May 2011, 03:58 PM
Try going to the Property Builder for the gridview, then select the master template and uncheck Allow Drag To Group. I have only used RadControls for a few days so I could be wrong :)
0

Deborah
Top achievements
Rank 1
answered on 13 May 2011, 04:34 PM
Thanks, Kyle. I tried during off all of the Allow xxx flags. Did not seem to help.
0

Emanuel Varga
Top achievements
Rank 1
answered on 16 May 2011, 09:25 AM
Hello Deborah,
You can use the following, but this will also disable dragging to group functionality.
First you will need to get the drag drop service:
after that from my tests I found that the best combination of events to get this to work properly is to use the PreviewDragHint to prevent the DragDropService from drawing the cell and PreviewDragOver to stop the DragDropOperation.
Maybe there is some cleaner solution, but i can't tell on a first glance.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
You can use the following, but this will also disable dragging to group functionality.
First you will need to get the drag drop service:
var dragDropService = radGridView1.GridViewElement.GetService<RadGridViewDragDropService>()
as
RadGridViewDragDropService;
after that from my tests I found that the best combination of events to get this to work properly is to use the PreviewDragHint to prevent the DragDropService from drawing the cell and PreviewDragOver to stop the DragDropOperation.
void
dragDropService_PreviewDragOver(
object
sender, Telerik.WinControls.RadDragOverEventArgs e)
{
var service = sender
as
RadGridViewDragDropService;
if
(service !=
null
&& !radGridView1.AllowColumnReorder && e.DragInstance
is
GridHeaderCellElement)
{
service.Stop(
false
);
}
}
void
dragDropService_PreviewDragHint(
object
sender, Telerik.WinControls.PreviewDragHintEventArgs e)
{
e.UseDefaultHint =
false
;
e.DragHint =
null
;
}
Maybe there is some cleaner solution, but i can't tell on a first glance.
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
0
Hi guys,
Thank you all for writing.
Emanuel's suggestion is a good approach for covering this case. However, I have added a feature request in PITS and we will improve RadGridView behavior in this scenario. Feel free to follow this link and add your vote for this request.
@Deborah, thank you for bringing this to our attention. Your Telerik points have been updated for this request.
Should you guys have any other questions or suggestions, do not hesitate to contact us.
Best wishes,
Stefan
the Telerik team
Thank you all for writing.
Emanuel's suggestion is a good approach for covering this case. However, I have added a feature request in PITS and we will improve RadGridView behavior in this scenario. Feel free to follow this link and add your vote for this request.
@Deborah, thank you for bringing this to our attention. Your Telerik points have been updated for this request.
Should you guys have any other questions or suggestions, do not hesitate to contact us.
Best wishes,
Stefan
the Telerik team