I have seaching for a day don’t get example how to implement thousand dan decimal separator in textbox.
Its possible we make thousand and decimal separator for input textboxt?
example i want display : 1,000,000.50
Thanks for the help.
Nicky
It’s easy to implement with Wisej.
This is a rough example that you need to adapt to your requirements in terms of format, filter, etc. I would create a derived class and manage it there:
this.textBox1.Filter = "[\\d,\\.]"; private void textBox1_Leave(object sender, System.EventArgs e) { if (Decimal.TryParse(this.textBox1.Text, out decimal value)) this.textBox1.Text = value.ToString("n"); }
Filter is a regular expression filter (see regexp documentation). For the formatting refer to .NET formatting guide.
In some implementations I have seen apps that remove the formatting in the Enter event. It’s a matter of requirements.
Hi Nicky..
That’s how I did it, I hope it helps you…
nValor = Convert.ToDecimal(txtTotal.Text.ToString());
txtTotal.Text = nValor.ToString(“#,##0.00”);
Regards
JC
Hi Nicky,
did you try using a MaskedTextBox ?
It should help you achieve what you want.
Best regards
Frank
Please login first to submit.