Can someone tell me how I could click on a column header and drag it away from its GridView, into another ListBox for instance - without loosing the standard Telerik in-GridView drag&drop features (column grouping for instance)?
It seems that if I implement the traditional drag & drop event capture, I can drag away the column but then the fancy drag & drop of columns inside the GridView are not accessible anymore.
I've tried to capture the DragLeave event, but it is not fired when in-GridView drag is active.
Thanks in advance,
Ze Jibe
8 Answers, 1 is accepted
0
Hello Ze,
Thank you for the question.
I prepared a sample drag and drop implementation from RadGridView (columns) to RadListBox. It is working correctly on my side and you keep the columns' drag and drop functionality inside RadGridView.
I hope this helps. If you have additional questions, feel free to contact me.
Sincerely yours,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Thank you for the question.
I prepared a sample drag and drop implementation from RadGridView (columns) to RadListBox. It is working correctly on my side and you keep the columns' drag and drop functionality inside RadGridView.
I hope this helps. If you have additional questions, feel free to contact me.
Sincerely yours,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Ze
Top achievements
Rank 1
answered on 26 Apr 2009, 08:03 AM
Fantastic, thanks a lot Nikolay.
Works like a charm, and example is crystal clear !
Cheers,
Ze Jibe
0
Ze
Top achievements
Rank 1
answered on 26 Apr 2009, 07:56 PM
Sorry, I'm still missing something: when the user drags a column away from the GridView and over the ListBox, the mouse cursor does not change (it remains in a state indicating drop is not allowed). To make the user experience perfect, would it be possible to change the state of the mouse cursor? (I've tried to capture the MouseEnter event from the ListBox but it is not fired when the user is in drag&drop mode)
Or any other clue that migth help the user understand he/she is actually allowed to drop the column in the ListBox?
Ze Jibe
0
Hello Ze,
In order to improve the user experience, you can use the following code snippet in the MouseMove event handler:
In the above code snippet if the ControlBoundingRectangle of ListBoxElement contains point, we set the Cursor to Arrow. I am attaching an updated version of my sample project for your reference.
If you have additional questions, feel free to contact me.
Sincerely yours,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
In order to improve the user experience, you can use the following code snippet in the MouseMove event handler:
Point point = this.radGridView1.PointToScreen(e.Location); |
point = this.PointToClient(point); |
if (this.radListBox1.ListBoxElement.ControlBoundingRectangle.Contains(point)) |
{ |
this.Cursor = Cursors.Arrow; |
} |
In the above code snippet if the ControlBoundingRectangle of ListBoxElement contains point, we set the Cursor to Arrow. I am attaching an updated version of my sample project for your reference.
If you have additional questions, feel free to contact me.
Sincerely yours,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Ze
Top achievements
Rank 1
answered on 27 Apr 2009, 06:47 PM
Excellent, exactely what I needed.
Thanks a lot for this great support !
Ze Jibe
0
Hi Ze,
I am glad to hear that I was of help.
All the best,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
I am glad to hear that I was of help.
All the best,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Thierry Loo
Top achievements
Rank 1
answered on 28 Apr 2009, 03:14 PM
Hi,
I've had a look at the code you provided, and it works great.
However I have two issues that I'm bumping into:
Do you see any solution to these issues ?
Thank you.
I've had a look at the code you provided, and it works great.
However I have two issues that I'm bumping into:
- The code is not using the standard drag and drop behavior of .net, so I cannot really know that I'm coming from the GridView when the MouseUp event is launched on the ListBox (e;g. if I have other controls on the form...)
- I have now generic way to know what object was actually dragged
- If I'm dragging a gridview cell instead of the column, it's going to do the drag-drop anyway
- If I want to prevent dragging the column for whatever reason (e.g. if it's column 0, and I don't want it to be dragged) I have no way to prevent it, because everything happens at Drop (that is MouseUp) time.
Do you see any solution to these issues ?
Thank you.
0
Hello Thierry Loo,
Thank you for your feedback.
Please find the answers to your questions below:
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Thank you for your feedback.
Please find the answers to your questions below:
- Indeed, you cannot determine that you are coming from, since this is not the standard drag and drop implementation of .NET. However, with this approach, you can easily benefit from the built-in ouline of the column header cell when a column is dragged. Generally, you are free to make your own drag and drop implementation which will best suits your needs and scenarios.
- There is a way to get the dragged element. You can take the element in the MouseDown event handler of RadGridView with the help of the GetElementAtPoint method. For additional information please refer to the attached project.
- I addressed the desired behavior in the attached project - you will not be able to drag and drop a column by dragging a data cell. You will only be able to drag and drop a column if you drag its header.
- In the MouseDown event handler you can make an implementation which will allow you to drag and drop a column only if a certain condition is met. In my sample project if a column has ColumnIndex 0, you cannot drag the column.
I hope this helps. If you have additional questions, feel free to contact me.
Kind regards,Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.