Very bizarre, I displayed the values using a message box and they were what I expected, even so it only worked when using the text property rather than the value
On Dec 16, 9:13 am, Benj Nunez <[email protected]> wrote: > Put your code under the Validating Event. Use the "Text" property > instead of "Value" > as indicated > here:http://dotmad.blogspot.com/2007/11/validation-of-numericupdown-contro... > > See if that will resolve your issue. > > Benj > > On Dec 16, 1:53 am, Markarina <[email protected]> wrote: > > > > > I'm using some very basic code found in the visual studio help to do > > some error checking on values entered on a form, it all works fine > > until I try to do validation on a numericupdown control, and then I > > get stuck in the control I am validating. Validation code is below: > > > private void numericUpDown2_Validated(object sender, EventArgs > > e) > > { > > // If all conditions have been met, clear the > > ErrorProvider of errors. > > errorProvider1.SetError(numericUpDown1, ""); > > } > > > private void numericUpDown2_Validating(object sender, > > CancelEventArgs e) > > { > > if ((numericUpDown2.Value + numericUpDown2.Value) > 8) > > { > > // Cancel the event and select the text to be > > corrected by the user. > > e.Cancel = true; > > > // Set the ErrorProvider error with the text to > > display. > > this.errorProvider1.SetError(numericUpDown2, "Data > > cannot go beyond message bounds, offset + number of bytes must be less > > than or equal to 8"); > > } > > > }
