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

Hide PropertyGridItem

7 Answers 804 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Pauli
Top achievements
Rank 2
Pauli asked on 19 Jan 2013, 12:03 PM
I view class instance in property grid and I want hide some of properties. How can I do it?

7 Answers, 1 is accepted

Sort by
0
Pauli
Top achievements
Rank 2
answered on 22 Jan 2013, 10:49 AM
Is it so that nobody does not know howto prevent property value to be shown in property grid. 
0
Laksmono
Top achievements
Rank 1
answered on 23 Jan 2013, 08:18 AM
Use BrowsableAttribute and set to false to hide the property

public class A
{
          [Browsable(false)]
          public string HiddenProperty{ get; set; }
}
0
Accepted
Ivan Petrov
Telerik team
answered on 23 Jan 2013, 08:47 PM
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.
0
Pauli
Top achievements
Rank 2
answered on 09 Feb 2013, 12:36 PM
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.
0
Grégory
Top achievements
Rank 1
answered on 27 Apr 2015, 04:02 PM

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.

 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 30 Apr 2015, 11:00 AM
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.

 
0
Grégory
Top achievements
Rank 1
answered on 30 Apr 2015, 11:43 AM
Thank you so much, it's fixed now !
Tags
PropertyGrid
Asked by
Pauli
Top achievements
Rank 2
Answers by
Pauli
Top achievements
Rank 2
Laksmono
Top achievements
Rank 1
Ivan Petrov
Telerik team
Grégory
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or