We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Custom Type Conversion Validation

Thread ID:

Created:

Updated:

Platform:

Replies:

2939 Feb 21,2003 05:53 AM Jan 20,2004 04:17 PM Windows Forms 5
loading
Tags: GridControl
Kai Iske
Asked On February 21, 2003 05:53 AM

Hi, I have a question concerning custom type conversion validation. I do not want to have the grid display the messages "x is not a valid value for type y" I want to have it display some more meaningful/understandable messages in the form of " You have supplied an invalid input. x is not a valid Number " At the moment I have it implemented using an override for the grid's OnCurrentCellValidating actually mimicing the functionality implemented in GridCellRendererBase.cs that way that I call up GridCellValueConvert.Parse and then throwing appropriate exceptions for all the CellValueTypes I want to be able to deal with. This is, somehow, redundant. If there was a way to plug in some message supplier for the standard validation routines, I would be very happy. Thanks for your help. Regards Kai Iske DWS Investments

Administrator [Syncfusion]
Replied On February 21, 2003 07:39 AM

Hi Kai, The problem you describe is quite common and we will offer more customization for parsing values in future version. There will be an event then that lets you hook in before the value gets converted to the result type. Stefan

Administrator [Syncfusion]
Replied On January 20, 2004 02:41 PM

Hi, I am running into same problem with the error messages in my DataBound grids (Syncfusion 1.6.1.8/VS.NET 2003/XP). Is there any way to intercept the errors (and/or exceptions) and show my own user friendly messages when incorrect data is entered into dates, int and decimal fields? An example of how to go about doing this at a cell level would be great. thanks, - Reddy

Administrator [Syncfusion]
Replied On January 20, 2004 02:56 PM

If you want to do the validation yourself, you can handle CurrentCellValding and set the message there. pre> private void gridDataBoundGrid1_CurrentCellValidating(object sender, CancelEventArgs e) { GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell; if(!cc.Renderer.ControlText.StartsWith("r")) { e.Cancel = true; cc.ErrorMessage = "Must start with r"; } } If you catch the ValidateFailed event, you can just set the message. private void grid_ValidateFailed(object sender, GridValidateFailedEventArgs e) { e.Handled = true; GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell; cc.ErrorMessage = "SomeMessage"; }

Administrator [Syncfusion]
Replied On January 20, 2004 03:06 PM

Clay, In our application we allow dates from 1/1/1901 to 12/31/9999. If I enter 1/1/10000, grid is giving a popup window "Valid values are between 1 and 9999, inclusive. Parameter name:year". If I type "abc" into a date cell, grid shows an error "The string was not recognized as a valid DateTime. There is a unknown word starting at index 0." Similarly, if I enter "abc" into an integer column it gives some error dialog on its own. Business users will have no clue about what we are talking about in these error dialogs, unless we give them a user fiendly error messages. I already have this CurrentCellValidating event handler attached. I am not getting a chance to handle this kind of errors in the event handler. thanks, - Reddy

Administrator [Syncfusion]
Replied On January 20, 2004 04:17 PM

Are you in a GridDataBoundGrid? If so, try catching the ValidateFailed event, and set the CurrentCell.ErrorMessage at that point. As far as the CurrentCellValidating, is it being hit prior to the display of the messages you mentioned above. If so, if you directly validate the string (not relying on the grid to do so) in CurrentCellValidating, and then you can set CurrentCell.ErrorMessage to display a custom message. Here is a little sample that requires you to enter an integer, and displays a custom message if you do not.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;