MaskedTextBox error

  • Thread starter Thread starter Paolo
  • Start date Start date
P

Paolo

I have a maskedtextbox (msktxtbxAmount)defined thus: Mask $#####.## and
msktxtbxAmount.ValidatingType = typeof(System.Decimal) with a PromptChar of =.

I have defined: decimal transAmount and the following event handler:

private void msktxtbxAmount_TypeValidationCompleted(object sender,
TypeValidationEventArgs e)
{
if (!e.IsValidInput)
{
MessageBox.Show("Invalid amount", "Error",
MessageBoxButtons.OK);
}
else
{
transAmount = (decimal)e.ReturnValue;
}
}

After data entry the text shows "$===35.00" yet I am showing the "Invalid
Amount" error message.

Can anyone point out where I have gone wrong?

Thanks
 
OK, if I amend the TextMaskFormat property to ExcludePromptsAndLiterals' the
input is accepted. However if I input 135.00, what is returned is 13500.

So how do I get 135.00 to be returned?
 
Can you divide by 100?

Paolo said:
OK, if I amend the TextMaskFormat property to ExcludePromptsAndLiterals' the
input is accepted. However if I input 135.00, what is returned is 13500.

So how do I get 135.00 to be returned?
 
Back
Top