c# - 具有空和非空类别的 WinForms PropertyGrid

标签 c# winforms propertygrid

是否有任何方法可以自定义 Winforms PropertyGrid,如果它需要在顶部(整行)显示一个没有类别的元素,而在下面显示几个包含元素的类别?

最佳答案

using System;
using System.ComponentModel;
using System.Windows.Forms;
static class Program {
    [STAThread]
    static void Main() {
        Application.EnableVisualStyles();
        using (var form = new Form {
            Controls = {
                new PropertyGrid { Dock = DockStyle.Fill,
                    SelectedObject = new Test {
                        Foo = "one element without category",
                        Bar = "several categories",
                        Blip = "with elements",
                        Blap = "inside",
                        Blop = "below"
                    }}}}) {
            Application.Run(form);
        }
    }
}
class Test {
    [Category(" ")] public string Foo { get; set; }

    [Category("x")] public string Bar{ get; set; }
    [Category("x")] public string Blip { get; set; }

    [Category("y")] public string Blap { get; set; }
    [Category("y")] public string Blop { get; set; }
}

关于c# - 具有空和非空类别的 WinForms PropertyGrid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4322150/

相关文章:

javascript - FullCalendar 未显示在 Asp.Net Core Razor View 中

c# - 在同一行有多个工具条

c# - 如何使用 WinForms PropertyGrid 编辑字符串列表?

windows - 错误1001。初始化安装时发生异常

winforms - Inherited Control Visible/Enabled 属性值 Always True : PropertyGrid

c# - 如何设置属性网格的选定项

c# - 多线程 C# 应用程序日志文件锁定问题

c# - 调用存储过程并检查返回值

c# - 缩放 SKImage (SkiaSharp) 的最快方法

winforms - Winform treeview 排序属性很慢