How do I get the current cursor position in a TextBox

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
 
T

Tony Johansson

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
 
T

Tony Johansson

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
 
M

Michaela Julia

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top