Link to home
Start Free TrialLog in
Avatar of Barbless
Barbless

asked on

Calculate Cursor Position in a NumericUpDown Text Area

Hello All,

I need to find the position of the cursor "|" in a string of "100.00|0" in the NumericUpDown Text box.  The end goal is to determine its position relative to the decimal point.

Thanks in advance for your help,
Barbless
Avatar of bungHoc
bungHoc
Flag of Viet Nam image

You can use the SelectionStart and SelectionLength properties.

If no text is selected then SelectionLength will be zero.

Hope it helps.
ASKER CERTIFIED SOLUTION
Avatar of discon0
discon0
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Barbless
Barbless

ASKER

discon0 - your solution not only works, it works beautifully! Thanks so much.

There is, however, a minor annoyance though - the cursor "|" is reset to the leftmost position on the text field when the up and down arrows are clicked.  How do I stop that from happening?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This works beautifully too! Thanks so much.
Hi Barbless -
Welcome to EE.
I deleted a duplicate question here: https://www.experts-exchange.com/questions/22909776/Get-Cursor-Position-in-a-Text-Field.html 

You can select up to three different Zones for each of your questions to be posted in - but please refrain from asking the same question more than once.

Thank you,


Vee_Mod
Experts Exchange Moderator
Didn't know I was doing that. The two questions were related, but had enough twists for them to be separate.
One more thing about the question that you deleted. The advice from discon0 was EXCEPTIONALLY good and he deserved all of the 250 points earned.  But because of the deletion, they were taken away from him/her.

Is there any way to reinstate those points discon0 rightfully earned?

I don't understand that comment at all.
You 'split-points' on that one among all three Experts who responded.
The only thing that discon0 posted was a link back to this question.

One suggestion I have is that each question remain only one question - rather than adding additional questions as you go.
Sometimes, 'follow-up' questions are needed for clarification and we all understand that.

When you have an additional question, create it in the Zones and then post a link to it in your old question.

The Experts who worked with you on the original question will get notification of the posted link and can help you (and themselves) by answering the new question and getting additional points.
Avatar of Bob Learned
Those two questions aren't exactly the same (but close enough), and the previous question has a link to this question (as proof that the same answer can apply to both).  This is a near-perfect example of bypassing the 500 point limit for getting a question answered.

Zone Advisor
You suggestion is well taken. I guess in the heat of finding a solution to a very tough problem, its easy to forget the site rules.

Back to the deleted question, again on discon's advice, despite being just a link to the other question, the most important thing for me was it actually solved the problems, that's why I awarded him the most points, and others got partial points for their efforts.

It wasn't apparent to me when I posted the two questions they would share  a common solution, it just worked out that way, and worked beautifully too.

And finally to Bob, I wasn't thinking of bypassing anything. I was too busy with finding a solution for that. In fact, discon0's solution did so much for me I wish there could be more points for him/her.
Barbless -
Your comments are understood and well taken - and as a Premium Service member, there is 'no harm-no foul' if you had made this: http:#a20141639 an entirely new question.

Keep that in mind for any future (or current) questions and you will be able to reward folks for the effort AND RESULTS they put forth.

Thank you again.


Vee_Mod

edit to add: "AND RESULTS"
Experts Exchange Moderator