473,395 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Position of Cursor in Textbox

For a string that is being edited in a textbox, is there a way to find
the position of the edit cursor in the string being edited? For
example, it would be 0 or 1 at the beginning of a string and go up by
one each time the right arrow key was pressed.

Thanks Much,
Gene in NC
Nov 20 '05 #1
2 2121
The SelectionStart property of the textbox should give you the position of
the cursor. You should also check the SelectionLength property as this will
tell you if the use has selected an area of the text and not just placed the
cursor in the textbox.

Kirk

TextBox1.SelectionStart
"Gene Hubert" <gw******@hotmail.com> wrote in message
news:7e*************************@posting.google.co m...
For a string that is being edited in a textbox, is there a way to find
the position of the edit cursor in the string being edited? For
example, it would be 0 or 1 at the beginning of a string and go up by
one each time the right arrow key was pressed.

Thanks Much,
Gene in NC

Nov 20 '05 #2
Hey Gene -

This little snippit should help:

Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp
Debug.WriteLine(TextBox1.SelectionStart())
End Sub
Josh Moody
VSU Team

--

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.
--------------------
From: gw******@hotmail.com (Gene Hubert)

For a string that is being edited in a textbox, is there a way to find
the position of the edit cursor in the string being edited? For
example, it would be 0 or 1 at the beginning of a string and go up by
one each time the right arrow key was pressed.

Thanks Much,
Gene in NC


Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: jason | last post by:
I've got this javascript routine (i found on google - thank you) in an asp.net page that on page reload sets the cursor of a textbox to the last line. It works great! Using a similar concept, I...
7
by: Steve | last post by:
does any one know a way to determine the position of the cursor in a text box. I would like to position a list next to the current position for context commands. I am using...
0
by: Jed Ozone | last post by:
In a TextBox, I'm using a MouseMove event to track the cursor position. I want to get able to tell what text the current cursor position is at so I can set the SelectionStart to that position. ...
2
by: DaveR | last post by:
Can anybody help me to a)get the user's cursor insertion point (caret) from a multiline textbox, using client-side script I suppose, and then b)return the position to VB code behind? I have...
4
by: Neil Robbins | last post by:
Could anyone suggest a way in which I could find the position of the cursor within a textbox. I want to evaluate every keypress made within the textbox in order to validate it but in order to do...
2
by: Agnes | last post by:
In my Textbox, User will input a date e.g "2004-12-06" How can I check the curosr position if the user use mouse or arrow to move the cursor position in the textbox ? e.g "2004-12-06" if user move...
3
by: Adriana Camargo | last post by:
Hi I have to change automatically the text inside a textbox. I need to add thousand separator when I am writting in the textbox. I am using TextChanged event and when I insert a new number, i...
4
by: Brandon McCombs | last post by:
Does anyone know of an easy way to set the position of the cursor in a TextBox? If I set text in the box that is longer than the length of the TextBox the position of the cursor is at the very end...
2
dj12345
by: dj12345 | last post by:
i have function to make character in lowercase if a text is in uppercase function upperCase(x) { try { var y=document.getElementById(x).value; ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.