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

Category Show after hiding all properties at runtime.

2 Answers 162 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Chuck
Top achievements
Rank 1
Chuck asked on 16 Jul 2015, 09:03 PM

I am using 

radPropertyGrid1.Items["Text"].Visible = variable;
to hide or show properties at run time.
The only negative side effect I'm seeing is that the Category doesn't disappear.
Is there a way to hide the category as well?

I've attached a picture of it visible, and of it hidden.
The category is Motion System Locations.

2 Answers, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 17 Jul 2015, 11:30 AM
Hello Chuck,

Thank you for writing.

When you hide all PropertyGridItems for a certain group you should hide the PropertyGridGroupItem as well:
public Form1()
{
    InitializeComponent();
 
    this.radPropertyGrid1.ToolbarVisible = true;
    PropertyStoreItem intItem = new PropertyStoreItem(typeof(int), "Integer", 1);
    PropertyStoreItem floatItem = new PropertyStoreItem(typeof(float), "Float", 1f, "Property storing a floating point value.");
    PropertyStoreItem stringItem = new PropertyStoreItem(typeof(string), "String", "telerik", "Property storing a string value", "Telerik");
    PropertyStoreItem dockItem = new PropertyStoreItem(typeof(DockStyle), "Dock", DockStyle.Top, "Property containing DockStyle value", "Layout", false);
     
    RadPropertyStore store = new RadPropertyStore();
    store.Add(intItem);
    store.Add(floatItem);
    store.Add(stringItem);
    store.Add(dockItem);
 
    this.radPropertyGrid1.SelectedObject = store;
}
 
private void radButton1_Click(object sender, EventArgs e)
{
    radPropertyGrid1.Items["Integer"].Visible = false;
    radPropertyGrid1.Items["Float"].Visible = false;
 
    foreach (PropertyGridGroupItem groupItem in this.radPropertyGrid1.PropertyGridElement.PropertyTableElement.Groups)
    {
        bool areAllItemsHidden = true;
        foreach (PropertyGridItem item in groupItem.GridItems)
        {
            if (item.Visible)
            {
                areAllItemsHidden = false;
                break;
            }
        }
        if (areAllItemsHidden)
        {
            groupItem.Visible = false;
        }
        else
        {
            groupItem.Visible = true;
        }
    }
}

I hope this information helps. Should you have further questions, I would be glad to help.
 
Regards,
Dess
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Chuck
Top achievements
Rank 1
answered on 17 Jul 2015, 01:00 PM
Thanks, that was exactly what I was looking for.
Tags
PropertyGrid
Asked by
Chuck
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Chuck
Top achievements
Rank 1
Share this question
or