In a .NET 4 C# WinForms app, I have a few NumericUpDown controls on a particular form. When inputting values at runtime to test, the minimum and maximum values are enforced as expected, except on one control.
I’ve set the .Maximum to 86400 and the .Minimum to 3 on the problem control. At runtime, it is only allowing values from 51 (!) to 86400.
The designer (auto-generated) code looks like this:
this.numEvilControl.Minimum = new decimal(new int[] {
3,
0,
0,
0});
I’ve cleaned and rebuilt the project, but to no avail.
What’s causing this control to come up with its own .Minimum value? I don’t know where to begin to look.
Rather than delete the question, I thought I would post how I found the problem…
As it turns out, there was a
.ValueChangedevent which was modifying the value (which I had long forgotten about).So, to all those who might have this problem in the future, check your events before you start wondering why properties are being magically altered!