Validate Data in the Windows Forms DataGridView Control  
Samples:
private void dataGridView1_CellValidating(object sender,
DataGridViewCellValidatingEventArgs e)
{
// Validate the CompanyName entry by disallowing empty strings.
    if (dataGridView1.Columns[e.ColumnIndex].Name == "CompanyName")
{
if (e.FormattedValue.ToString() == String.Empty)
{
dataGridView1.Rows[e.RowIndex].ErrorText =
"Company Name must not be empty";
e.Cancel = true;
}
}
}

相关文章:

  • 2022-12-23
  • 2022-02-12
  • 2022-12-23
  • 2021-12-25
  • 2021-11-30
  • 2019-10-21
猜你喜欢
  • 2021-10-22
  • 2021-12-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-03-08
  • 2022-12-23
相关资源
相似解决方案