验证DataGridView单元格中只能输入负数
做出入库,验证DataGridView单元格中只能输入负数~ --------------------编程问答-------------------- private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e){
double d= 0.0;
dataGridView1.Rows[e.RowIndex].ErrorText = string.Empty;
if(dataGridView1.Columns[e.ColumnIndex].DataPropertyName == "A")
{
if(!double.TryParse(e.FormattedValue.ToString(),out d) || d>0.0)
{
dataGridView1.Rows[e.RowIndex].ErrorText = "输入有误!";
e.Cancel = true;
}
}
}
补充:.NET技术 , C#