473,587 Members | 2,508 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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
Nov 15 '05 #1
2 9246
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******** ********@TK2MSF TNGP09.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

Nov 15 '05 #2
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" <kw*****@yahoo. com> wrote in message
news:OX******** ******@TK2MSFTN GP09.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" <st*@srasys.co. in> wrote in message
news:OC******** ********@TK2MSF TNGP09.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


Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1733
by: Chris Barrow | last post by:
Hi everyone, Does anyone know if it is possible to append your own javascript function onto the end of a button's onclick method when validation controls are used? Here is an example of the script that is generated when validation controls are use on the form: onclick="{if (typeof(Page_ClientValidate) != 'function'
3
2353
by: simon | last post by:
I have 2 <asp:textbox controls>: <asp:textbox id="txt1" Runat="server" ></asp:textbox> <asp:textbox id="txt2" Runat="server" ></asp:textbox> User must insert the value either in txt1 OR in txt2, so one of them shouldn't be empty. So I use custom validator:
1
2419
by: Stephen Adam | last post by:
Hi there, I have written a custom validation control which checks to see of an input field is not empty and contains only numeric data. I was using a regular expression validation control but was unable to get it fail if a field was blank. My problem now is that while my custom validation control will detect if a field matches my...
6
2679
by: jk | last post by:
Looking through WebUIValidation.js, I discovered that the standard validators don't cater for non-numeric date formats (e.g. dd-MMM-yyyy) which I would like to do To keep code to a minimum, I would like to extend the existing validator to handle other common date formats and still be able to do both client and/or server side validation as...
5
2636
by: | last post by:
Hi all, Has anyone been able to write some custom javascript on the onclick event of submit button to do certain things like disable submit button, only submit form once etc. This was a breeze in 1.1 since I could edit the .js file. Now in 2.0 I can no longer do this. Also, my code would have to be called after all client-side validation...
1
2648
by: Fendi Baba | last post by:
I wrote a simple validation routine. I am trying to trigger validation on group of fields if an option on another radio button is selected. Sub ValidateAdd_ServerValidate(ByVal objSource As Object, ByVal objArgs As ServerValidateEventArgs) if radioDbutton.SelectedItem.Value="yes" Then
2
19443
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's...
1
4376
by: asharda | last post by:
I have a custom property grid. I am using custom property grid as I do not want the error messages that the propertygrid shows when abphabets are entered in interger fields. The custom property grid doesn't show colloections i.e. if I have a List<Objectthen the Collection is shown but when I click on the "..." button next to it nothing...
0
2897
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's...
0
7923
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7852
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7974
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5719
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2364
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1192
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.