I have a calculator app that has a display like real calculators. Now I want to add digit grouping to it, that enhance the readability of the display. I added this code to my app, and it worked fine for integer numbers, but it doesn't show the fraction point in decimal numbers. I used double for defining the variables, but I don't know where the problem is.
private void txtDisplay_TextChanged(object sender, EventArgs e)
{
btnPoint.Enabled = !txtDisplay.Text.Contains(".");
btnBackSpace.Enabled = Convert.ToBoolean(txtDisplay.Text.Length);
//digit grouping the number in textbox
if (txtDisplay.Text.Length > 0)
{
dblGroupedNumber = Convert.ToDouble(txtDisplay.Text);
txtDisplay.Text = string.Format("{0:n0}", dblGroupedNumber);
}
}