2010-11-03 6 views

Répondre

1

Utilisez le CellValidating événement: (.) ​​

private void dataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) 
{ 
    if (e.ColumnIndex == theColumnToValidate.Index) 
    { 
     decimal d; 
     if (!decimal.TryParse(e.FormattedValue.ToString(), out d)) 
     { 
      MessageBox.Show("Please enter a decimal number"); 
      e.Cancel = true; 
     } 
    } 
} 
+0

Salut thomas je travaille ce KeyPress événement et le fait, mais problème est que je ne suis pas en mesure de valider que sur le point – Nagendra

+0

si (Char.IsLetter (e. KeyChar)) { e.Handled = true; } – Nagendra

+0

Tapez Ctrl + V pour annuler ce type de code. La validation est correcte. –

Questions connexes