Avatar of HLRosenberger
HLRosenberger
Flag for United States of America asked on

Strrange behavior using masked edit

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.
Visual Basic.NET.NET Programming

Avatar of undefined
Last Comment
HLRosenberger

8/22/2022 - Mon
HLRosenberger

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

ASKER
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 Moreau

This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
AndyAinscow

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

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

ASKER
Not surprised, really I guess.  I guess there's not way to truly have no prompt character.
ASKER CERTIFIED SOLUTION
AndyAinscow

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
HLRosenberger

ASKER
yup, I'll do it myself in code. thanks.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.