How do I get the current cursor position in a TextBox

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
T

Tony Johansson

Hello!

I want to drag a file into a TextBox by using DragDrop and this works fine.
I also want to drop this file where I have the cursor positioned in the
TextBox.

So my question is how do I get the current cursor position in the TextBox ?

//Tony
 
Hello!

Now I have to mark at least one character in the TextBox.
This works but I have to select a place in the TextBox.

I just wonder is it possible to get the position of the cursor without
having to select
a position in the TextBox.

//Tony
 
Hello!

According to the Doc it says.
SelectionStart = Gets or sets the starting point of text selected in the
text box. (Inherited from TextBoxBase.)

So it work as long as I select a Text in the TextBox where the dragged file
is inserted into the TextBox

But I hope there is a way to get the cursor position without having to
select a piece of text in the TextBox

//Tony
 
Tony said:
But I hope there is a way to get the cursor position without having to
select a piece of text in the TextBox
You.Do.Not.Have.To!
SelectionStart will _always_ return the cursor position.
If nothing is selected SelectionLength will be 0.
That's all there is to it.
 
Back
Top