Category Show after hiding all properties at runtime.

3 posts, 1 answers
  1. Chuck
    Chuck avatar
    9 posts
    Member since:
    Oct 2012

    Posted 16 Jul 2015 Link to this post

    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. Answer
    Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3378 posts

    Posted 17 Jul 2015 Link to this post

    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
  3. Chuck
    Chuck avatar
    9 posts
    Member since:
    Oct 2012

    Posted 17 Jul 2015 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Thanks, that was exactly what I was looking for.
Back to Top