Re: C# - How to raise custom Validation Message in Property Grids?

From: Shanthi (stm_at_srasys.co.in)
Date: 02/23/04


Date: Mon, 23 Feb 2004 16:14:15 +0530

Thanks for the reply.

I agree with you that overriding the system exception may not be a good
idea.
What I need is to validate the inputs to the propety grid.
I am trying to resolve this problem from another angle now.
Is it possible to validate key strokes while the user enters so that I can
disallow chars where the fields need to be numeral. Looking for some key
board / data change events on the property grid.

Thanks & Regards
Shanthi

"Ben Rush" <kwendex@yahoo.com> wrote in message
news:OXlLTjd#DHA.3668@TK2MSFTNGP09.phx.gbl...
> I'm not sure as though I understand.
>
> You mean you have a property of your type, say, "prop" that is of type
> System.Int32, and so is used like thus -
>
> .......
> MyObj.prop = 4;
> .......
>
> and you want to override exceptions you get when you try to set it to
> something invalid, like thus -
>
> .......
> MyObj.prop = "blah";
> .......
>
> My first assumption would be, no, you can't and shouldn't override the
> default exceptions you'd get back. My feelings are that if I could
> circumvent the exceptions, somehow, that would get generated by
> mis-assignment of types that would be a major flaw in the type-safety of
the
> .Net runtime itself.
>
> Remember that properties are functions. And what you're trying to do is,
> from within the function, catch an invalid parameter value AFTER it has
> already been constructed on the stack-frame for that function,
type-checked
> and so forth. I don't see how this is possible.
>
>
> "Shanthi" <stm@srasys.co.in> wrote in message
> news:OCYaFEd%23DHA.2664@TK2MSFTNGP09.phx.gbl...
> > I am using property grid in C# application. Property grid displays the
> > propeties properly. But I have some problem in displaying custom
> validation
> > message.
> > I have integer type property. When I give invalid values for the
property
> it
> > is throwing System exception as follows.
> >
> > "Invalid Property Value. Is not a valid value for Int32.
> >
> > Though I have custom validation message in the Property set system
throws
> > exception before this.
> >
> > Is there any way to override system defined exception?
> >
> > How can I avoid this?
> >
> > Can anyone help in this?
> >
> > Thanks in advance.
> >
> > Regards
> > Shanthi
> >
> >
>
>



Relevant Pages

  • JNLP validation
    ... I then I tried validating one of my JNLP files. ... the JNLP 6.0 validating XSD schema. ... a program to use the scheme to validate the JNLP. ... catch (Exception e) ...
    (comp.lang.java.programmer)
  • Unable to validate data after idle
    ... This crash occurs on every clients at same time, ... Exception of type System.Web.HttpUnhandledException was thrown. ... Exception Details: System.Web.HttpException: Unable to validate data. ... [HttpException: Authentication of viewstate failed. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: DataGrid ArgumentOutofRange Exception
    ... When exception is thrown, check the Call Stack window. ... Right-click on it and ensure that "Show non-user code" is on. ... Before removing an item from the collection, I set the DataSource of the grid = Nothing. ... This caused the grid to re-display with the removed item gone, but as soon as I clicked on the grid, I got the exception. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: catching multiple exceptions
    ... Throws InvalidOperationException if not set. ... Address.Street as string. ... The "problem" is that once you cause an exception, ... but have a Validate method in the object that validates the ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Validating input parameters
    ... If the parameters were not what you expected them to be, throw an exception. ... Yes, you should validate the parameters, unless you really know that they ... > internal ClassName(Database dbToUse, Int64 pk,DateTime Date) ... and if so in case of an invalid error whats the best way to report ...
    (microsoft.public.dotnet.languages.csharp)

Loading