Question tree view drag and drop to text box at cursor position

anil3b2

Member
Joined
Jun 19, 2009
Messages
14
Programming Experience
1-3
I need to drag and drop to textbox from tree view. Here while drag and drop to text box i need to add the dragged text to anywhere in the text box which we have already dragged some nodes here.

For example.
in treeview i have "node1" and "node2"

now i am going to add "node2" to textbox and in front of "node2" i need to add "node1" and then at the end of "node2" again i need to drop "node1" like that.

How can i achieve this? Please suggest
 
DragEventArgs in DragDrop event provides x/y coordinate of the mouse pointer in screen coordinates, you can translate this to client coordinate with the Textbox PointToClient method. Then use the Textbox GetCharIndexFromPosition method to find the char index where to drop the text. To actually place the text there you could for example use the Select method to select the index position and set SelectedText.
Documentation for TextBox Class (System.Windows.Forms)
 
Back
Top