Answers for "c# textbox integer"

C#
1

c# winforms textbox to int

int userVal = Int32.Parse(txtboxname.Text);
Posted by: Guest on August-30-2021
0

c# textbox numbers only

private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
    if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) &&
        (e.KeyChar != '.'))
    {
            e.Handled = true;
    }

    // only allow one decimal point
    if ((e.KeyChar == '.') && ((sender as TextBox).Text.IndexOf('.') > -1))
    {
        e.Handled = true;
    }
}
Posted by: Guest on May-04-2021

C# Answers by Framework

Browse Popular Code Answers by Language