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

Hide base class properties for some types

1 Answer 171 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 2
Martin asked on 07 Mar 2013, 01:30 PM
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

Label:
Don't show IsReadOnly 
TextBox:
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?

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 12 Mar 2013, 04:37 PM
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,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
PropertyGrid
Asked by
Martin
Top achievements
Rank 2
Answers by
Maya
Telerik team
Share this question
or