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" <st*@srasys.co.in> wrote in message
news:OC****************@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