예제 #1
0
 private void TxtDNI_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (!(char.IsNumber(e.KeyChar)) && (e.KeyChar != (char)Keys.Back))
     {
         frmMessageBoxNumber frm = new frmMessageBoxNumber();
         frm.ShowDialog();
         e.Handled = true;
         return;
     }
 }
예제 #2
0
        private void TxtSalary_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (((e.KeyChar < 48 || e.KeyChar > 57) && e.KeyChar != 8 && e.KeyChar != 46))
            {
                frmMessageBoxNumber frm = new frmMessageBoxNumber();
                frm.ShowDialog();
                e.Handled = true;
                return;
            }

            // checks to make sure only 1 decimal is allowed
            if (e.KeyChar == 46)
            {
                if ((sender as TextBox).Text.IndexOf(e.KeyChar) != -1)
                {
                    frmMessageBoxPoint frm = new frmMessageBoxPoint();
                    frm.ShowDialog();

                    e.Handled = true;
                }
            }
        }