Strrange behavior using masked edit

Posted on 2016-07-21
Last Modified: 2016-07-22
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.
Question by:HLRosenberger
  • 4
  • 2

Author Comment

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

Author Comment

ID: 41723492
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 = ""
LVL 69

Expert Comment

by:Éric Moreau
ID: 41723502
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

LVL 44

Expert Comment

ID: 41723552
>>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 Comment

ID: 41723686
Not surprised, really I guess.  I guess there's not way to truly have no prompt character.
LVL 44

Accepted Solution

AndyAinscow earned 500 total points
ID: 41723756
>> 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 Closing Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Sending a Secure fax is easy with eFax Corporate ( First, just open a new email message. In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now