NumericUpdown and ErrorProvider problems

134 views
Skip to first unread message

Markarina

unread,
Dec 15, 2009, 12:53:56 PM12/15/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
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");
}

}

Benj Nunez

unread,
Dec 16, 2009, 4:13:21 AM12/16/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
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-control.html


See if that will resolve your issue.




Benj

Markarina

unread,
Dec 16, 2009, 9:11:31 AM12/16/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
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 <benjnu...@gmail.com> 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...
Reply all
Reply to author
Forward
0 new messages