2010-12-01 52 views

Répondre

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; } 
} 
+0

Non, il va créer une catégorie avec string.Empty comme nom. Laissez-moi vous expliquer avec le lien http://xmages.net/storage/10/1/0/7/d/upload/5ec8a40d.png - il y a une catégorie Prop1 à l'intérieur, mais je veux montrer Prop1 sans aucune catégorie (un niveau en haut). –

+0

@ Lonli-Lokli - alors; non –

+1

@Lonli - vous pouvez essayer http://www.visualhint.com/ –