Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...