472,779 Members | 2,842 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

MaskedTextBox Cursor Position

We have some dumb and lazy people here, so I need help.

To fix the dumb part: We have placed MaskedTextBoxes on the forms so they
will stop entering the information incorrectly.

Now the lazy part: When our people click on a blank MaskedTextBox field, the
cursor does not automatically go to the first "non-filled" mask value.

For Example: Take the MaskedTextBox "___-___-___". When our people click the
Text area, their cursor may stop at "___-_|_-___" (as noted by the '|'
character) instead of "|__-___-___" (the start of the Text area).

As another Example: Take the partially filled MaskedTextBox "123-4__-___".
When our people mouse-click into the Text area, the cursor should position
anywhere between position 0 and 5, not where the click event happened.

I realize this is happening because the control's Text field is physically
populated with the mask, and I am trying to work around this programmatically
in the code.

In my MaskedTextBox, I have set the CutCopyMaskFormat Property to
"ExcludePromptAndLiterals," but this did not solve my problem.

Also, I have tried setting the SelectionStart property whenever the control
receives focus, but this does not move the cursor.

How do I position the cursor in a MaskedTextBox?
Feb 11 '08 #1
1 9001
In the mouse up event of maskedtextbox write the following code........
SendKeys.Send("{HOME}")

Whenever you will enter your mouse in the textbox,the cursor will be moved to the starting position.....

Aug 27 '08 #2

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

Similar topics

1
by: Dan H. | last post by:
Hello, I want to try to retrieve the cursor position x and y relative to the form the cursor is over. The way I am doing it now is: 1. Retrieve the left and top position of the form relative...
1
by: Tantra Veda | last post by:
Hello C# gurus, I have a question about finding cursor position in NumericUpDown control. On my form I have a numericUpDown control with 2 decimal places. I want to increment value in the numeric...
1
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...
1
by: Paul | last post by:
Hi all, I am making a DirectInput application wich must report correctly the cursor position in windowed mode (it means it has to be the same as Microsoft Window´s cursor position). First of...
22
by: DraguVaso | last post by:
Hi, For my application I need the following behavior: When I press F4 the cursor has to move to the next line in my multiline textbox which begins with "0". Finding lines starting with 0 isn't...
3
by: Mike Fellows | last post by:
I have a few masked textboxes within my application and I have the same problem with each and everyone If I tab to a masked textbox i have no issues, but when i click into a mask textbox the...
0
by: =?Utf-8?B?Sm9hY2hpbQ==?= | last post by:
Can you make the MaskedTextbox to only allow certain letters e.g. 10:11 A (Only allow A and P as input) ?? I don't want any other letters than A or P to appear in the text box. I mean no...
1
by: eljainc | last post by:
Hello, I am trying to utilize a MaskedTextBox control on my form. I would like the user to enter numbers only (i.e. 65000), I set the Mask property as 999999 and the PromptChar as space (it...
4
by: mike | last post by:
I have the opportunity to rescue a project that uses a mouse to sense the relative position of a machine. The hardware is built...just needs to be programmed. Stop snickering!!! I didn't do it...I...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.