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?
Declare uint type variable
minimum of uint is 0
maximun od uint is 4294967295
The upper part of the question should be easily solved like this:
dgv.Columns[i].ValueType = typeof(uint);
The lower part I don't understand at all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With