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

Does RadPropertyGrid support RegularExpressionAttribute?

2 Answers 44 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Andrea
Top achievements
Rank 1
Andrea asked on 13 Nov 2013, 05:47 PM
As per message subject, does radPropertyGrid support RegularExpressionAttribute for validation? I can't find a mention in documentation.


2 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 18 Nov 2013, 12:24 PM
Hello Andrea,

Actually, this issue is more related to the binding being notified and the TextBox having the error displayed rather than the support of the property grid itself. What you can is:
1. Define the property (for example):

[RegularExpression(@"^[a-zA-Z''-'\s]{1,10}$", ErrorMessage = "Characters are not allowed.")]
       public string Name
       {
           get { return this.name; }
           set
           {
               if (value != this.name)
               {
                   Validator.ValidateProperty(value, new ValidationContext(this, null, null) { MemberName = "Name" });
                   this.name = value;
                   this.OnPropertyChanged("Name");
               }
           }
       }
 
2. Define the property definition:
<telerik:RadPropertyGrid Item="{Binding Clubs[0]}" >
            <telerik:RadPropertyGrid.PropertyDefinitions>
                <telerik:PropertyDefinition Binding="{Binding Name, ValidatesOnDataErrors=True, NotifyOnValidationError=True, ValidatesOnExceptions=True}" />
            </telerik:RadPropertyGrid.PropertyDefinitions>
        </telerik:RadPropertyGrid>


Regards,
Maya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Andrea
Top achievements
Rank 1
answered on 18 Nov 2013, 03:11 PM
Thank you, the exception was of course thrown by the underlying database after server-side checks.

Ok i will let properties throw exception and set binding validateonerrors etc on autogenerate property event.

Best regards
Tags
PropertyGrid
Asked by
Andrea
Top achievements
Rank 1
Answers by
Maya
Telerik team
Andrea
Top achievements
Rank 1
Share this question
or