hi
can any body help
the fallowing code i can able to enter data 250.00 in text box
if (e.KeyChar == '.' && (sender as TextBox).Text.IndexOf('.') > -1)
{
e.Handled = true;
}
if (!char.IsControl(e.KeyChar))
{
TextBox tt = (TextBox)sender;
if (tt.Text.IndexOf('.') > -1 && tt.Text.Substring(tt.Text.IndexOf('.')).Length >= 3)
{
e.Handled = true;
}
}
after enter 250.00 this i changes to 25.00 by using back. after that i am not able to enter any number.
Loading
Sanjeeb LenkaPosted Aug 30, 2013, 6:12 AM
if ((e.KeyChar < '0' || e.KeyChar > '9') && (e.KeyChar != '\b') && (e.KeyChar != '.'))
{
e.Handled = true;
}
else
{
e.Handled = false;
}
if (Char.IsControl(e.KeyChar))
{
e.Handled = false;
}
else if (Char.IsNumber(e.KeyChar) || e.KeyChar == '.')
{
TextBox tb = sender as TextBox;
int cursorPosLeft = tb.SelectionStart;
int cursorPosRight = tb.SelectionStart + tb.SelectionLength;
string result = tb.Text.Substring(0, cursorPosLeft) + e.KeyChar + tb.Text.Substring(cursorPosRight);
string[] parts = result.Split('.');
if (parts.Length > 1)
{
if (parts[1].Length > 2 || parts.Length > 2)
{
e.Handled = true;
}
}
}
venkata kumarPosted Aug 30, 2013, 6:06 AM
after dot symbol it is taking more than 2 digits
i want after dot only 2 digits
Sanjeeb LenkaPosted Aug 30, 2013, 5:56 AM
if ((e.KeyChar < '0' || e.KeyChar > '9') && (e.KeyChar != '\b') && (e.KeyChar != '.'))
{
e.Handled = true;
}
else
{
e.Handled = false;
}
if (Char.IsControl(e.KeyChar))
{
e.Handled = false;
}
else if (Char.IsNumber(e.KeyChar) || e.KeyChar == '.')
{
TextBox tb = sender as TextBox;
int cursorPosLeft = tb.SelectionStart;
int cursorPosRight = tb.SelectionStart + tb.SelectionLength;
string result = tb.Text.Substring(0, cursorPosLeft) + e.KeyChar + tb.Text.Substring(cursorPosRight);
string[] parts = result.Split('.');
if (parts.Length > 1)
{
if (parts.Length > 2)
{
e.Handled = true;
}
}
}
venkata kumarPosted Aug 30, 2013, 5:35 AM
without deleting the dot in the textbox i want to edit the numbers before dot.....
venkata kumarPosted Aug 30, 2013, 2:28 AM
thank you for reply.
your code after dot symbol it is talking more than 2 digits.
after dot symbol need to allow 2 digits.
venkata kumarPosted Aug 30, 2013, 2:21 AM
what ever you given code same pbm. what ever i am getting pbm.
first step i entered number 258.00
second step i deleted number 8 by using back button (25.00)
third step i am entering some number after 5 it is not taking.(254.00)
that 4 is not taking
Kunal VaishyaPosted Aug 30, 2013, 1:08 AM