1
I need to have in an entry a money mask, I’m trying some things I got information, follows:
void lanceMask(object sender, EventArgs e)
{
var ev = e as TextChangedEventArgs;
if (ev.NewTextValue != ev.OldTextValue)
{
var entry = (Entry)sender;
string text = Regex.Replace(ev.NewTextValue, @"[^0-9]", "");
text = text.PadRight(9);
//Removendo todos os digitos excedentes
if (text.Length > 8)
{
text = text.Remove(8);
}
if (text.Length < 5)
{
text = text.Insert(1, ".").TrimEnd(new char[] { ' ', '.', '-', ',' });
}
else
{
text = text.Insert(5, ".").Insert(7, ",").TrimEnd(new char[] { ' ', '.', '-', ',' });
}
if (entry.Text != text)
entry.Text = text;
}
}
I would like to be able to use the semicolon if it had 6 digits (ex: 1,400.00), if it is 7 digits (ex: 23,600.00), and so on.
Very good. Remembering that you can accept your own answer :)
– Dherik