This is a migrated thread and some comments may be shown as answers.

AllowColumnReorder

4 Answers 104 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Deborah
Top achievements
Rank 1
Deborah asked on 12 May 2011, 08:24 PM
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?

4 Answers, 1 is accepted

Sort by
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:
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
Stefan
Telerik team
answered on 18 May 2011, 08:34 AM
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
Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
Tags
GridView
Asked by
Deborah
Top achievements
Rank 1
Answers by
Kyle
Top achievements
Rank 1
Deborah
Top achievements
Rank 1
Emanuel Varga
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or