TextBox enduser input for decimal is not working C# - VS2010 Silverlight


hello,

i developing program enduser input price...basically 9.99, when go in debug mode not let input decimal until numbers in , can use arrow key put cursor in place want decimal , allow enter it. please help!!

private void textbox1_textchanged(object sender, textchangedeventargs e)
        {

            if (double.tryparse(textbox1.text, out value1))
            {
                textbox1.text = value1.tostring();
            }
            if (textbox12.text.endswith("1") || textbox16.text.endswith("2") || textbox16.text.endswith("3") ||textbox16.text.endswith("4") || textbox16.text.endswith("5") || textbox16.text.endswith("6")  || textbox16.text.endswith("8") || textbox16.text.endswith("9") ||textbox16.text.endswith("0") == true && (value1 < 100))
            {
                value69 = 1;
                textbox69.text = value69.tostring();
            }
            if (textbox12.text.endswith("1") || textbox16.text.endswith("2") || textbox16.text.endswith("3") ||textbox16.text.endswith("4") || textbox16.text.endswith("5") || textbox16.text.endswith("6")  || textbox16.text.endswith("8") || textbox16.text.endswith("9") ||textbox16.text.endswith("0") == true && (value1 > 100) && (value1 < 149.99))
            {
                value69 = 2;
                textbox69.text = value69.tostring();
            }
            if (textbox12.text.endswith("1") || textbox16.text.endswith("2") || textbox16.text.endswith("3") ||textbox16.text.endswith("4") || textbox16.text.endswith("5") || textbox16.text.endswith("6")  || textbox16.text.endswith("8") || textbox16.text.endswith("9") ||textbox16.text.endswith("0") == true && (value1 > 149.99))
            {
                value69 = 3;
                textbox69.text = value69.tostring();
            }

            if (textbox1.text == null || textbox1.text == "") value1 = 0;
            {
                textbox1.text = value1.tostring();
            }
            if (textbox1.text.endswith(".97") == true)
            {
                value20 = 0; value36 = 0; value69 = 0;
                textbox20.text = value20.tostring();
                textbox36.text = value36.tostring();
                textbox69.text = value69.tostring();
            }
        }

 i'm using following code following code textboxes item price

//textbox 1 thru 16 allows enduser enter price of item.

private void textbox2_textchanged(object sender, textchangedeventargs e)

{

double value2;

if (double.tryparse(textbox2.text, out value2))

try

{

textbox2.text = value2.tostring();

}

catch

{

messagebox.show("please enter valid decimal textbox!")

}

}

when run debugger, can enter numbers if try enter decimal places cursor in front of numbers entered instead of enter it. example want 99.99, when enter it put.9999. can place while typing in textbox instead of trying arrow add correctly.

another example have , doing same thing above is:

private void textbox20_textchanged(object sender, textchangedeventargs e)
        {
            double value20;

            var numberstyle = numberstyles.allowleadingwhite |
         numberstyles.allowtrailingwhite |
         numberstyles.allowleadingsign |
         numberstyles.allowdecimalpoint |
         numberstyles.allowthousands |
         numberstyles.allowexponent;
            if (double.tryparse(textbox20.text, numberstyle, cultureinfo.invariantculture, out value20))
                textbox20.text = value20.tostring();

            else
                messagebox.show("please enter percent value via decimal structure.");

        }



Silverlight  >  Designing with Silverlight



Comments

Popular posts from this blog

Motherboard replacement

Cannot create Full Text Search catalog after upgrading to V12 - Database is not fully started up or it is not in an ONLINE state

Remote Desktop App - Error 0x207 or 0x607