c# - 在节目中展开 C# propertygrid

标签 c# propertygrid

我有一个关于属性网格的问题。 当显示表格时,我希望展开而不是折叠一个组。 我在网上搜索了很多,但还没有找到。 任何想法。

最佳答案

如果您想展开网格中的所有项目,这非常简单。属性网格有一个方法可以做到这一点:

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/

相关文章:

C# PropertyGrid - 检查当前是否正在编辑一个值

C# 序列化在子类中删除属性?

c# - 如何从文本文件中删除逗号的最后一个索引?

c# - Orleans grain 代码中的响应式(Reactive)扩展

c# - 有没有一种方法可以在 azure 函数启动后立即调用通过依赖项注入(inject)注入(inject)的类中的方法?

c# - 关闭后 IWindowsFormsEditorService 延迟

用户控件中的事件

c# - 托管 C++ dll 中的 XmlnsDefinition

C# 窗体 : PropertyGrid not updated when item added to Collection

c# - PropertyGrid UITypeEditor 禁用单元格编辑