Ver Mensaje Individual
  #7 (permalink)  
Antiguo 16/03/2010, 10:48
Ka0stj
 
Fecha de Ingreso: febrero-2010
Ubicación: México
Mensajes: 738
Antigüedad: 14 años, 2 meses
Puntos: 37
Respuesta: Problema con validacion

Haber trata con el keyDown

Código c#:
Ver original
  1. private void txtNit_KeyDown(object sender, KeyEventArgs e)
  2.         {
  3.  
  4.             if (e.KeyCode == Keys.Enter)
  5.             {
  6.  
  7.                 if (txtNit.Text != "")
  8.                 {
  9.  
  10.                     for (int i = 0; i < dgvPersonas.Rows.Count; i++)
  11.                     {
  12.  
  13.                         if (dgvPersonas.Rows[i].Cells[0].Value != null)
  14.                         {
  15.  
  16.                             if (dgvPersonas.Rows[i].Cells[0].Value.ToString() == txtNit.Text.ToString())
  17.                             {
  18.  
  19.                                 MessageBox.Show("El nit introducido ya existe", "..Datos Repetidos..", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  20.  
  21.                                 i = dgvPersonas.Rows.Count;
  22.  
  23.                                 sw = 1;
  24.  
  25.                                 limpiar();
  26.  
  27.                             }
  28.                            
  29.                         }
  30.  
  31.                     }
  32.  
  33.  
  34.                 }
  35.  
  36.             }
  37.         }

Si presionas enter lo invocas. Verifica que en las propiedades de tu Form este como true keypreview