Is there any way to customize Winforms PropertyGrid, if it needs to show one element without category on top (full row) and several categories with elements inside below?
Asked
Active
Viewed 825 times
1 Answers
2
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; }
}

Marc Gravell
- 1,026,079
- 266
- 2,566
- 2,900
-
No, it will create category with string.Empty as name. Let me explain with link http://xmages.net/storage/10/1/0/7/d/upload/5ec8a40d.png - there is a Prop1 inside category, but I want to show Prop1 without any categories (one level up). – Lonli-Lokli Dec 01 '10 at 07:58
-
Thanks, but we prefer to use MS components to avoid hash. – Lonli-Lokli Dec 01 '10 at 14:45