I'm trying to show and hide groups and single items of a PropertyGrid depending on the answers inside the same propertyGrid.
I've seen that a good place to set the visibility of the group is in when the grid is created, in this function:
sender, CreatePropertyGridItemElementEventArgs e)
var myItem = (MyItem)groupItem.Group.GroupItem.GridItems.Value;
groupItem.Visible = myItem.EnableGroup;
var myItem = (MyItem)item.Value;
item.Visible = myItem.EnableItem;
However, I'm not able to change the visibility at a second time, since this function is not called again later.
If I try to change the visibility of the VisualItem in OnItemFormatting, the items are hidden, but the spaces are not recalculated and the design is messed up.
Also, if I try to change the visibility of an item at the end of OnEdited, OnItemFormatting goes on loop.
Any hint? :)