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

Hide nestedproperties

1 Answer 109 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
payal
Top achievements
Rank 1
payal asked on 30 May 2016, 04:19 PM

I want to hide the properties which has nested properties inside them. What is best approach to do them? Ihave tries following things

1. setting NestedPropertiesVisibility="Hidden" for radpropertygrid. But it not working.

2. setting visiblility of propertydefinition based on displayname.The code looks like

private void PropertyGrid1_AutoGeneratingPropertyDefinition(object sender, AutoGeneratingPropertyDefinitionEventArgs e)
      {
          if (e.PropertyDefinition.DisplayName == "Mypropertyname")
          {
              e.PropertyDefinition.Visibility = Visibility.Hidden;  
          }
      }

second approach works but I dont want to do on the basis of Displayname.I need to be hidden if any propertydefinition under property has nested property

 

Would you please help me with the same.

 

 

1 Answer, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 31 May 2016, 01:39 PM
Hello Payal,

You can make use of the Browsable attribute in order to tell RadPropertyGrid to not display a certain PropertyDefinition. Here is an example:

public class Order
{
    public string ShipAddress { get; set; }
    public string ShipCountry { get; set; }
    public string ShipName { get; set; }
    public string ShipPostalCode { get; set; }
 
    [Browsable(false)]
    public Employee Employee { get; set; }
}

The other approach, as you've guessed, is to handle the AutoGeneratingPropertyDefinition event. However, other than checking a hard-coded DisplayName value, the only available option is to check the PropertyDefinition's SourceProperty and base your logic on that.

Would any of these approaches be suitable to your requirements?

Regards,
Dilyan Traykov
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
PropertyGrid
Asked by
payal
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Share this question
or