我有一个关于属性网格的问题。 当显示表格时,我希望展开而不是折叠一个组。 我在网上搜索了很多,但还没有找到。 任何想法。
最佳答案
如果您想展开网格中的所有项目,这非常简单。属性网格有一个方法可以做到这一点:
propertyGrid.ExpandAllGridItems();
如果是你想扩展的某个群体可以用这个方法:
private static void ExpandGroup(PropertyGrid propertyGrid, string groupName)
{
GridItem root = propertyGrid.SelectedGridItem;
//Get the parent
while (root.Parent != null)
root = root.Parent;
if (root != null)
{
foreach (GridItem g in root.GridItems)
{
if (g.GridItemType == GridItemType.Category && g.Label == groupName)
{
g.Expanded = true;
break;
}
}
}
}
关于c# - 在节目中展开 C# propertygrid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4086105/