Does RadPropertyGrid support RegularExpressionAttribute?

3 posts, 0 answers
  1. Andrea
    Andrea avatar
    52 posts
    Member since:
    Oct 2012

    Posted 13 Nov 2013 Link to this post

    As per message subject, does radPropertyGrid support RegularExpressionAttribute for validation? I can't find a mention in documentation.


  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 18 Nov 2013 Link to this post

    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Andrea
    Andrea avatar
    52 posts
    Member since:
    Oct 2012

    Posted 18 Nov 2013 Link to this post

    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
Back to Top