I’m not sure I am setting this up correctly so I’ve attached a simple sample app to show the problem.
I’m programmatically adding rows to a DataGridView. Double clicking on one of the Quantity cells or typing a number whilst one is selected causes an error.
Value of ‘0’ is not valid for ‘Value’. ‘Value’ should be between 1 and 100.
Parameter name: Value
Thanks
Nic
You are using the DataGridViewNumericUpDownColumn which takes in values. But the code assigns string values. Also the NumericUpDown editor has its value range between 0 and 100 by default. You can change that setting the properties of the column.
In alternative you can use the DataGridViewTextBoxColumn and set the ValueType to int to force the integere data conversion.
This change works in your test case:
dataGridView1.Rows.Add(“Item 1”, 4);
dataGridView1.Rows.Add(“Item 2”, 3);
dataGridView1.Rows.Add(“Item 3”, 2);
dataGridView1.Rows.Add(“Item 4”, 1);
Please login first to submit.