473,786 Members | 2,849 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Find the cursor position in a textbox

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 this I need to know where the cursor is when
the key is pressed. So far I can't see how I could do this.

Any help would be very much appreciated,

Neil R.
Nov 20 '05 #1
4 6259
Hi,

TextBox1.MouseP osition

Ken
----------------------
"Neil Robbins" <ne**@talent-centre.com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
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 this I need to know where the cursor is
when
the key is pressed. So far I can't see how I could do this.

Any help would be very much appreciated,

Neil R.

Nov 20 '05 #2
Hi Ken,

Thanks for the response, unfortunately I think that perhaps I should have
been a little more specific.

I need to to know the location of the text cursor, not the mouse cursor. So
if there are 10 characters allowed in the textbox and the user has entered a
string of 6 characters but has gone back to edit the third character I need
to know that it is the third character that is being edited and not the
second (or any other) character.

I hope that this clarifies things a little.

Any further help would be greatly appreciated.

Neil R.
"Ken Tucker [MVP]" <vb***@bellsout h.net> wrote in message
news:Oy******** *****@TK2MSFTNG P10.phx.gbl...
Hi,

TextBox1.MouseP osition

Ken
----------------------
"Neil Robbins" <ne**@talent-centre.com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
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 this I need to know where the cursor is
when
the key is pressed. So far I can't see how I could do this.

Any help would be very much appreciated,

Neil R.


Nov 20 '05 #3
* "Neil Robbins" <ne**@talent-centre.com> scripsit:
Thanks for the response, unfortunately I think that perhaps I should have
been a little more specific.

I need to to know the location of the text cursor, not the mouse cursor. So
The text cursor is called caret.
if there are 10 characters allowed in the textbox and the user has entered a
string of 6 characters but has gone back to edit the third character I need
to know that it is the third character that is being edited and not the
second (or any other) character.


Maybe you are looking for the control's 'SelectionStart ' property?

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4
Thanks Herfried thats just what I was looking for.

Neil R.

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:2h******** ****@uni-berlin.de...
* "Neil Robbins" <ne**@talent-centre.com> scripsit:
Thanks for the response, unfortunately I think that perhaps I should have been a little more specific.

I need to to know the location of the text cursor, not the mouse cursor. So

The text cursor is called caret.
if there are 10 characters allowed in the textbox and the user has

entered a string of 6 characters but has gone back to edit the third character I need to know that it is the third character that is being edited and not the
second (or any other) character.


Maybe you are looking for the control's 'SelectionStart ' property?

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #5

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

Similar topics

7
9063
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 VS.NET/C#/System.Windows.Forms.
16
38201
by: Ramsin Savra | last post by:
Hi, What do you suggest to do if I want to do a search in TextBox ? I know that using RichTextBox, we could have Find method to search for a specific word or information but I was wonder if somebody knows some methods for Find and Replace in TextBox. Thanks
1
3889
by: objectref | last post by:
Hi to all, we have the MousePosition property that we can get the Point of the position of the mouse cursor on the screen, but is it there a way to get the respective Point of a cursor in a TextBox ?? (relative to screen) I mean, i have a textbox that i write some text and i want to know the exact point location of the cursor at any time a character is displayed.
5
2998
by: Tina | last post by:
How is it possible to designate a textbox so that when the .aspx page is displayed the cursor is already there so the user can just start typing instead of having to click in the textbox with the mouse first? thanks, T
6
8671
by: Andrea V.F. | last post by:
How can I determine the control under the mouse cursor when a user muves the mouse?? For example if the user moves the cursor over a textbox i would receive the name of that textbox without using the "MouseMove" event for that textbox. Thanks
3
5187
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 have a function that formats the complete text with thousand separator. For example, if textbox1 content is 1,234 and i added a number 5 after number 1, the result must be 15,234.
13
3387
by: WALDO | last post by:
I have a .Net TextBox (TextBoxBase, really) in which I am appending about 20 lines of text per second. I use the AppendText() method to accomplish this. This is a great substitute for taking the Text property and concatenating it... Me.tb.Text &= newText ' Instead use Me.tb.AppendText(newText) ....ultimately setting the SelectionStart to the end of TextBox, the
4
64888
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 of the line and a user would have to use the arrow keys to move it back to the beginning of the line of text. I'd prefer to set the cursor position automatically to just before the first character of the text. thanks
2
2421
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; document.getElementById(x).value=y.toLowerCase(); }
0
9647
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10164
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9961
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8989
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4066
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3669
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.