PC Review


Reply
Thread Tools Rate Thread

How do I get the current cursor position in a TextBox

 
 
Tony Johansson
Guest
Posts: n/a
 
      21st Apr 2009
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


 
Reply With Quote
 
 
 
 
Michaela Julia
Guest
Posts: n/a
 
      21st Apr 2009
Tony Johansson wrote:

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


Check out .SelectionStart
 
Reply With Quote
 
Tony Johansson
Guest
Posts: n/a
 
      21st Apr 2009
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

"www.ghoz.net |" <Mahmoud Ghoz> skrev i meddelandet
news:(E-Mail Removed)...
>I guess you mean caret. you should find property called SelectionStart
>
> Mahmoud Ghoz
> www.Ghoz.NET
>
>> Tony Johansson wrote:
>>
>>> So my question is how do I get the current cursor position in the
>>> TextBox ?
>>>

>> Check out .SelectionStart
>>

>
>



 
Reply With Quote
 
Michaela Julia
Guest
Posts: n/a
 
      21st Apr 2009
Tony Johansson wrote:
> This works but I have to select a place in the TextBox.

No, you don't ;-)
 
Reply With Quote
 
Tony Johansson
Guest
Posts: n/a
 
      21st Apr 2009
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


"Michaela Julia" <(E-Mail Removed)> skrev i meddelandet
news:%23Kaa%(E-Mail Removed)...
> Tony Johansson wrote:
>> This works but I have to select a place in the TextBox.

> No, you don't ;-)



 
Reply With Quote
 
Michaela Julia
Guest
Posts: n/a
 
      21st Apr 2009
Tony Johansson wrote:
> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cursor position in textbox raju Microsoft Access Form Coding 1 4th Sep 2006 02:34 PM
>> Cursor Position in textbox =?Utf-8?B?Sm9uYXRoYW4=?= Microsoft Access Form Coding 6 11th May 2006 06:03 AM
Textbox Cursor Position Will Lastname Microsoft ASP .NET 1 14th Sep 2005 07:21 AM
Cursor position in TextBox Doug Bell Microsoft VB .NET 1 24th Aug 2005 01:57 PM
Position of Cursor in Textbox Gene Hubert Microsoft VB .NET 2 24th Oct 2003 10:23 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:12 PM.