This is a migrated thread and some comments may be shown as answers.

How to show Validation Error Message for UserControls

1 Answer 307 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Maurizio
Top achievements
Rank 2
Maurizio asked on 01 Jul 2014, 08:26 AM
I'm using a UserControl to show and edit a specific property in RadPropertyGrid. In the setter of the property I throw a ValidationException if the user has entered some invalid value. The property looks like this:

public int MyProperty
{
    get { return _MyProperty; }
    set
    {
        if (value == -1)
            throw new ValidationException("My Validation error message");
 
        ...  
    }
}

It the user enters -1 a nice red frame appears around the UserControl in the PropertyGrid cell, but no Validation Tooltip!!!

If I use e. g. a Textbox to display data, there is a red validation Tooltip. How can I achieve this for my custom controls?

I don't like the the approach with a CustomValidationAttribute, because just throwing a ValidationException is much more straightforward...

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 03 Jul 2014, 07:59 AM
Hi Peter,

Generally, when you create some custom UserControl for editing, you will most probably need to implement the validation ToolTip on your own and be responsible for its bindings and display. I guess you will get the same behavior no matter if it is placed inside RadPropertyGrid, DataForm, RadGridView, Microsoft DataGrid, etc. 
However, everything depends on your exact scenario. Does the editing pass through a TextBox for example that has built-in validation ToolTip ? Is there a kind of toolTip implemented in your editing control ?


Regards,
Maya
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
PropertyGrid
Asked by
Maurizio
Top achievements
Rank 2
Answers by
Maya
Telerik team
Share this question
or