Hide PropertyGridItem

8 posts, 1 answers
  1. Pauli
    Pauli avatar
    15 posts
    Member since:
    Nov 2009

    Posted 19 Jan 2013 Link to this post

    I view class instance in property grid and I want hide some of properties. How can I do it?
  2. Pauli
    Pauli avatar
    15 posts
    Member since:
    Nov 2009

    Posted 22 Jan 2013 Link to this post

    Is it so that nobody does not know howto prevent property value to be shown in property grid. 
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Laksmono
    Laksmono avatar
    5 posts
    Member since:
    Jul 2012

    Posted 23 Jan 2013 Link to this post

    Use BrowsableAttribute and set to false to hide the property

    public class A
    {
              [Browsable(false)]
              public string HiddenProperty{ get; set; }
    }
  5. Answer
    Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 23 Jan 2013 Link to this post

    Hello Pauli and Laksmono,

    Thank you both for writing.

    The solution proposed by Laksmono is the right way to go in case you do not want the property to ever be added to the items collection of RadPropertyGrid. Another options is to set the Visible property of the particular item in the property grid Items collection:
    this.radPropertyGrid1.Items["propertyName"].Visible = false;
    I hope this is useful. Should you have further questions, I would be glad to help.

    Regards,
    Ivan Petrov
    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
  6. Pauli
    Pauli avatar
    15 posts
    Member since:
    Nov 2009

    Posted 09 Feb 2013 Link to this post

    Thanks Ivan and Laksmono
    I want to hide collections and Browsable is what I wanted but I can't use it because it prevents binding. Visible works well.
  7. Grégory
    Grégory avatar
    4 posts
    Member since:
    Apr 2015

    Posted 27 Apr 2015 Link to this post

    Hi,

    I have to use this ".Visible" trick instead of using [Browsable(false)] attribute, because I have to use binding on these properties in another form.

    It works fine, but unfortunaly the height of the RadPropertyGrid scrollbar don't ignore the hidden items (the scrollbar is the same if all items are shown or if i hide some of them. Please see attached image).

     Regards.

     

  8. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 30 Apr 2015 Link to this post

    Hello Grégory,

    Thank you for writing.

    When you modify the item's visibility, it is necessary to wrap it in a BeginUpdate/EndUpdate block. Thus, the PropertyTableElement will be refreshed properly and the scroll-bar will recalculates its value:
    public Form1()
    {
        InitializeComponent();
     
        RadPropertyStore store = new RadPropertyStore();
        for (int i = 0; i < 8; i++)
        {
            PropertyStoreItem item = new PropertyStoreItem(typeof(string), "Prop" + i, "Value" + i);
            store.Add(item);
        }
     
        this.radPropertyGrid1.SelectedObject = store;
    }
     
    private void radButton1_Click(object sender, EventArgs e)
    {
        this.radPropertyGrid1.PropertyGridElement.PropertyTableElement.BeginUpdate();
        this.radPropertyGrid1.Items["Prop5"].Visible = false;
        this.radPropertyGrid1.PropertyGridElement.PropertyTableElement.EndUpdate();
    }

    I hope this information helps. Should you have further questions, I would be glad to help.
     
    Regards,
    Dess
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  9. Grégory
    Grégory avatar
    4 posts
    Member since:
    Apr 2015

    Posted 30 Apr 2015 in reply to Dess Link to this post

    Thank you so much, it's fixed now !
Back to Top
UI for WinForms is Visual Studio 2017 Ready