Is there a way to know/set cursor position on DragOver and DragDrop methods for the FormattedTextEditor?
I'm doing something like a text editor and would like to drag&drop some text but cannot find the way to place it other than the beginning and the end of already written text.
Many thanks
An alternative to this approach is to apply a background colour of SystemColors.Highlight to the selected text, then move the SelectionStart to the mouse position using GetCaretPositionFromMouseLocation, and remove the background colour on MouseUp.
I found a simple way to achieve that instead of coding a DrawFilter: place a label with a black background color on top of the caret that is not blinking when dragging over.
Simply hide the label on DragDrop and DragLeave.
// Get the cursor position related to the window (not the screen) var localPoint = TextEditor.PointToClient(new Point(e.X, e.Y)); // Get the caret position inside the text editor int caretPosition = TextEditor.EditInfo.GetCaretPositionFromMouseLocation(localPoint); // Get the caret location computed from it's position Rectangle rect = TextEditor.EditInfo.GetCaretLocation(caretPosition); // Display a label where on top of the caret lblDropIndicator.Width = 2; lblDropIndicator.Height = rect.Height; lblDropIndicator.Location = rect.Location; lblDropIndicator.Visible = true;
There's no easy way to do that. What you would have to do is use a DrawFilter to draw onto the surface of the control during your drag operation. So you would have to determine the position at which to draw and then draw some kind of indicator yourself.
Sorry, my reply seems to have been lost.
It worked like a charm, but still want to show the cursor in the dragover event to let the user know where it will be dropped. Setting SelectionStart with SelectionLength=0 does not work.
Hello,
I am just checking about the progress of this issue. Let me know If you need any further assistance on this issue?
Thank you for using Infragistics Components.