Question should be self explanatory. I have a datagridview which has a column whose cells should accept only positive integer upon user input.
So how can I set something like this:
dgv.Columns[i].ValueType = typeof(int > 0);
??
Of course I can handle a separate validation at cellValueChanged event. But since I have all validation handled in DataError event automatically (since I set valueType for each column), I would like my above validation to be handled here
private void dgv_DataError(object sender, DataGridViewDataErrorEventArgs e)
{
// not fair..
e.Cancel = true;
}
How to?
Update: Since I hear a lot of negatives about uint (as proposed by one of the answers) like uints are not CLS compliant, not all language supports it etc, is it ok to use just for validation purpose like above?
The upper part of the question should be easily solved like this:
The lower part I don’t understand at all.