Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4046,6 +4046,66 @@ public void ShortcutKeys_GridEntry_ProcessInput()
index.Should().Be(-1);
}

[WinFormsFact]
public void PropertyGrid_ExpandAllGridItems_ExpandsNestedGridItems()
{
using PropertyGrid propertyGrid = new();
propertyGrid.SelectedObject = new MyClass();

GridItem nested = FindExpandableProperty(propertyGrid.SelectedGridItem);
Comment thread
ricardobossan marked this conversation as resolved.
nested.Should().NotBeNull();

propertyGrid.ExpandAllGridItems();

nested.Expanded.Should().BeTrue();
}

[WinFormsFact]
public void PropertyGrid_CollapseAllGridItems_CollapsesNestedGridItems()
{
using PropertyGrid propertyGrid = new();
propertyGrid.SelectedObject = new MyClass();

GridItem nested = FindExpandableProperty(propertyGrid.SelectedGridItem);
nested.Should().NotBeNull();

propertyGrid.ExpandAllGridItems();
nested.Expanded.Should().BeTrue();

propertyGrid.CollapseAllGridItems();
nested.Expanded.Should().BeFalse();
}

private static GridItem FindExpandableProperty(GridItem item)
{
GridItem root = item;
while (root.Parent is not null)
{
root = root.Parent;
}

return Find(root.GridItems);

static GridItem Find(GridItemCollection items)
{
foreach (GridItem item in items)
{
if (item.GridItemType == GridItemType.Property && item.GridItems.Count > 0)
{
return item;
}

Comment thread
ricardobossan marked this conversation as resolved.
GridItem found = Find(item.GridItems);
if (found is not null)
{
return found;
}
}

return null;
}
}

[WinFormsFact]
public void PropertyGrid_PropertyValueChanged_Invoke_CallsPropertyValueChanged()
{
Expand Down
Loading