May be My Question is not seems like a good one but here is the Description:
I am creating an application in this in a form i have a textbox which is taking input from user here is my Code
private void Form1_Load(object sender, EventArgs e)
{
textBox1.Text = string.Format("{0:0.##}", "0.00");
}
this will show value in textbox at pageload:0.00
Now after this if i click on backspace button of keyboard then
if (e.KeyChar.ToString() == ".")
{
e.Handled = true;
int b = textBox1.Text.LastIndexOf("00");
textBox1.SelectionStart = b;
}
else
{
string abc = "0";
string a = textBox1.Text.TrimStart(abc.ToCharArray());
textBox1.Text = a;
}
this code will lead me to here the textbox has now: .00 only
but after this when i enter some value then it will take values as;
2334.3423424
but i want to do like
2334.34
it means value should replace .00 only and user cant enter value after that.
This piece of code will restrict your user in entering only 2 digits after the decimal in your textbox.