예제 #1
0
        private void ApenasTexto(object sender, KeyPressEventArgs e)
        {
            string strAcentos = "ÄÅÁÂÀÃäáâàãÉÊËÈéêëèÍÎÏÌíîïìÖÓÔÒÕöóôòõÜÚÛüúûùÇç~´'^";

            if (strAcentos.IndexOf(e.KeyChar) > 0)
            {
                alertaErro alertaErro = new alertaErro("acento");
                alertaErro.ShowDialog();
                e.Handled = true;
            }
        }
        private void ApenasValorNumerico(object sender, KeyPressEventArgs e)
        {
            TextBox txt = (TextBox)sender;

            if (!char.IsDigit(e.KeyChar) && e.KeyChar != Convert.ToChar(Keys.Back))
            {
                if (e.KeyChar == ',')
                {
                    e.Handled = (txt.Text.Contains(','));
                }
                else
                {
                    e.Handled = true;
                    alertaErro alertaErro = new alertaErro("numero");
                    alertaErro.ShowDialog();
                }
            }
        }