You can add TextChanged event and do something like this (to be improved...) :
private void textBox1_TextChanged(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(textBox1.Text))
{
System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo();
nfi.NumberGroupSeparator = " ";
double nValue = 0;
bool bError = false;
try
{
nValue = double.Parse(textBox1.Text, System.Globalization.NumberStyles.AllowThousands, nfi);
}
catch (System.Exception se)
{
bError = true;
System.Windows.Forms.MessageBox.Show("Error : " + se.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
//if (!bError)
{
textBox1.Text = string.Format(nfi, "{0:N0}", nValue);
textBox1.Select(textBox1.Text.Length, 0);
}
}
}
}