Articles in this section
Category / Section

How to hide a particular type property in the PropertyGrid?

1 min read

HidePropertiesCollection Property:

You can hide a particular property by using the HidePropertiesCollection property in the Property Grid. Desired properties that are to be hidden can be added to the HidePropertiesCollection. For example, to hide the enum property type, this property has to be added to the HidePropertiesCollection. The following code example shows how to hide the enum property.

XAML

<syncfusion:PropertyGrid x:Name="pgrid" ButtonPanelVisibility="Visible"   
                SearchBoxVisibility="Visible" DefaultPropertyPath="Content"  SelectedObject="{Binding ElementName=button}"
                        DescriptionPanelVisibility="Visible" >
</syncfusion:PropertyGrid>
<shared:ButtonAdv x:Name="button" Label="Item" Width="100" Height="30"/>

C#

MainWindow Class:
public MainWindow()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(MainWindow_Loaded);
        }
        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            HideProperties(typeof(ButtonAdv));
            pgrid.RefreshPropertygrid();
        }
        private void HideProperties(Type type)
        {
         PropertyDescriptorCollection p = (PropertyDescriptorCollection)TypeDescriptor.GetProperties(type);
            foreach (PropertyDescriptor item in p)
            {
                if (item.PropertyType.IsEnum)
                {
                    pgrid.HidePropertiesCollection.Add(item.Name);
                }
            }
        }

The following screenshot hides a particular type property.

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied