Hide base class properties for some types

2 posts, 0 answers
  1. Martin
    Martin avatar
    39 posts
    Member since:
    Sep 2008

    Posted 07 Mar 2013 Link to this post

    I have an object hierarchy and for some of the classes I want to hide some properties for the propertygrid.

    In the baseclass FieldProperty I have IsReadOnly, IsReadOnly is OK for a textbox but not for a label.

    Let's sum it up

    Don't show IsReadOnly 
    Show IsReadOnly 

    I use the intersection mode for displaying objects with common properties so I need AutoGeneratePropertyDefinitions="True" and I also need to create custom editors.

    There are many more exceptions like this for all the other input types. I can't changes the object structure because the datalayer is already coded and there is not time to fix it.

    Can someone help me?

  2. Maya
    Maya avatar
    4062 posts

    Posted 12 Mar 2013 Link to this post

    Hi Martin,

    As far as I can understand, you do not want to have a particular property (IsReadOnly in this case) displayed in the property grid. If that is so, you can try handling AutoGeneratingPropertyDefinition and cancel the generation of a particular property. 
    For example:

    void propertyGrid_AutoGeneratingPropertyDefinition(object sender, Telerik.Windows.Controls.Data.PropertyGrid.AutoGeneratingPropertyDefinitionEventArgs e)
                if (e.PropertyDefinition.DisplayName == "IsReadOnly")
                    e.Cancel = true;

    Is that the behavior you are looking for ? 

    Kind regards,
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
Back to Top