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

What Event Should Be Used to Expand an Item

3 Answers 113 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 05 Sep 2013, 10:13 PM
I couldn't find a property to set that will always expand all property grid items, so now I'm trying to expand just one item when the property grid is loaded. I tried putting the Expand() call in the CreateItem event handler, but the item is always null. If I put the Expand() call in the ItemFormatting event handler, I am unable to collapse the item. Here is the code I'm using:

PropertyGridItem item = e.Item as PropertyGridItem;

if
(item.Label == "abc" && !item.Expanded)
{
    item.Expand();
}

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 10 Sep 2013, 01:17 PM
Hello Paul,

Thank you for writing.

There is a method that you can call during the OnLoad event of the form to expand all items in RadPropertyGrid:
radPropertyGrid1.ExpandAllGridItems();

This will expand all items in the control and the user will be able to collapsed them if needed.

I hope that you find this information useful.
 

Regards,
Stefan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Stevens
Top achievements
Rank 1
answered on 24 Sep 2015, 01:51 PM
Asking How to Expand a single item, not All.
0
Stefan
Telerik team
answered on 25 Sep 2015, 06:24 AM
Hi,

You mentioned that you find a way how to expand all the items, so I gave you how to do it.

To expand item, the PropertyGridItem type, has method which will expand the item if it is expandable. There is also Expanded property which you can set and which does the same.

If you want to expand only certain items, you can do that by using the SelectedObjectChanged event. 
private void RadPropertyGrid1_SelectedObjectChanged(object sender, PropertyGridSelectedObjectChangedEventArgs e)
{
    radPropertyGrid1.Items[5].Expand();
}

Once you assign the SelectedObject property of the control, this event will get triggered, and you will have access to the Items, from where you can expand the desired ones.

I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.

Regards,
Stefan
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
Tags
PropertyGrid
Asked by
Paul
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Stevens
Top achievements
Rank 1
Share this question
or