Strrange behavior using masked edit

HLRosenberger
HLRosenberger used Ask the Experts™
on
I have simple Windows form (not WEB app), a test app for this problem.  It has a masked Edit and a button.  mask is "00000000" (8 zeroes) and prompt char is a space, because I don't want a prompt char.  In button click event, I set the focus to the text box because in my real app depending on what the user enters, I do not close my dialog and instead force them to reenter data.   I can click the button all day and all is fine - textbox get focus.  However, if I use the mouse to click in the text box, I get 8 space (size of the mask) inserted into the text box.   Why? I don't get it??  See image.  I can tell this happens by seeing  the blinking cursor.  


spaces in textbox.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
oh, I get this behavior even without the button click.  Just clicking into the textbox, and I get the 8 spaces.

Author

Commented:
If I do this in the click event for the textbox, the cursor to the beginning of the text box, and now I can type into it.  Otherwise, with those spaces, I can't type.  

  MaskedTextBox1.Text = ""
Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

AndyAinscowFreelance programmer / Consultant

Commented:
>>mask is "00000000" (8 zeroes) and prompt char is a space

Why are you surprised that it works as you instructed it to work ??

Author

Commented:
Not surprised, really I guess.  I guess there's not way to truly have no prompt character.
Freelance programmer / Consultant
Commented:
>> I guess there's not way to truly have no prompt character.
Correct (for a masked edit control), for none then you have to code your own, which isn't that difficult for just an integer number.

Author

Commented:
yup, I'll do it myself in code. thanks.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial