How to make thousand and decimal separator in textbox

0
0

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

 

 

  • You must to post comments
0
0

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.

  • nicky suwandi
    Thanks Luca for your help. i try using filter like you example ( “{\d,\.}” ), it still hard to implement the value like -1,000,000.99 , before using wisej, i am using infragistics, so i am familiar using that tools, in infragistic we just using mask “-n,nnn,nnn.nn” to implement that value (user can input minus and 2 decimal digit). Regards Nicky
  • You must to post comments
0
0

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

Attachment
  • nicky suwandi
    Thanks JC for your example, i am using this way right now, but 1 have problem when user input with alphabet, in infragistic tools ,they have currencytextbox to handle this problem, but currency textbox don’t support with wisej. Thanks for your help Regards Nicky
  • You must to post comments
0
0

Hi Nicky,

did you try using a MaskedTextBox ?
It should help you achieve what you want.

Best regards
Frank

  • nicky suwandi
    Yes Frank, i am using MaskedTexbox with input text (because if i set to numeric, we cann’t put coma in there)
  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.