Re: C# - How to raise custom Validation Message in Property Grids?
From: Shanthi (stm_at_srasys.co.in)
Date: 02/23/04
- Next message: Tom Vergote: "Re: Is There the EOF in C#?"
- Previous message: ±èÀçȲ: "Is There the EOF in C#?"
- In reply to: Ben Rush: "Re: C# - How to raise custom Validation Message in Property Grids?"
- Messages sorted by: [ date ] [ thread ]
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
> >
> >
>
>
- Next message: Tom Vergote: "Re: Is There the EOF in C#?"
- Previous message: ±èÀçȲ: "Is There the EOF in C#?"
- In reply to: Ben Rush: "Re: C# - How to raise custom Validation Message in Property Grids?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|