I'm working with drag and drop from another control in my application. When I hold down the ctrl key, the text item copies from the other control into the syntax editor. Is there an easy way to get this to work without the user having to hold down the ctrl key?
I have been investigating into your requirement in this case, and I believe I will need a little more information on what exactly this “other control” that you are dragging from is. Would it be possible for you to please provide some information regarding that?
I ask, as I have put together a very simple sample project on my end that drags from a TextBox, and the Ctrl key is not required to “copy-drag” the selected text of the TextBox to the XamSyntaxEditor.
Please let me know if you have any other questions or concerns on this matter.
Thanks for the response. So when I do what you describe, and drag from a textbox to the xamsyntaxeditor, it performs a "move" and pastes the text correctly into the xamsyntaxeditor while removing it from the textbox. If I do the same from the textbox with the ctrl key down it performs a "copy".
My real issue is when dragging from a listbox control (which contains a list of strings), so I am essentially dragging in a string. When trying to drag without ctrl key pressed, I am unable to drop. When I hold down the ctrl key it lets me drop on the xamsyntaxeditor. Hopefully you can re-create this in your sample project. If not, let me know and I'll put together a sample project.
I have put together a sample project using a ListBox instead, and I am still not able to see this Ctrl copy behavior that you are referring to. Perhaps there is some setting that I am missing? I am attaching the sample project I am using to test this.
If you are looking to drag without the Ctrl key and the Ctrl key drag is something that is built-in to the ListBox in this case, the best thing I can recommend is to implement your own drag-drop functionality between the ListBox and the XamSyntaxEditor. There is a good example here about dragging between two ListBoxes that I think may help you, as if you modify this to be between the XamSyntaxEditor and the ListBox instead, I believe you can achieve your requirement.
I've put together a sample project which represents what is going on in our project. We use the "ATLDragAndDrop" class for all out listboxes and it allows us to drag to any other control from a listbox without holding the ctrl key.
I've put together a sample solution but I am unable to attach it. I've tried a few different browsers and it keeps giving an error.
Please let me know how to get the sample to you. Thanks
Still waiting on how to get you the sample project I've put together. Thanks
I apologize for the delay in my response.
In order to attach a sample project to the Infragistics forums, it needs to be less than 1MB in size. If the bin and obj folders are present in the project that you are trying to attach, please delete them prior to compressing your project, as this should normally make the size less than 1MB.
If you are still unable to attach the sample, I would then recommend sending it to firstname.lastname@example.org referencing this forum thread.
I've removed the bin and obj folders so that it will attach. Please review and let me know what you find out. Thanks
Thank you for the sample project. I have taken a look, and I can reproduce the behavior you are seeing. I am not entirely sure, but it looks like internally, we may be expecting that a copy-operation is coming from a “text editor” type of source, and so we expect that the Ctrl key is pressed when trying to handle a “Copy” drag-drop operation.
I have found a workaround to this, in that if in the PreviewMouseLeftButtonDown event in your ATLDragDrop class, you pass the “data” parameter as a string and set the DragDropEffects to be “All” instead of “Copy,” the drag works normally without the need to press the Ctrl key. I am unsure why exactly this is at the moment, to be honest, but I am attaching a modified version of the sample project you sent to demonstrate.
I hope this helps. Please let me know if you have any other questions or concerns on this matter.