WinForms PropertyGrid with empty and non-empty category

Is there a way to set up a Winforms PropertyGrid if it needs to show one element without a category on top (full row) and several categories with elements inside below?

+3
source share
1 answer
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; }
}
+2
source

Source: https://habr.com/ru/post/1777855/


All Articles