2010-12-01 38 views

回答

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

不,它會以string.Empty作爲名稱創建類別。讓我用鏈接http://xmages.net/storage/10/1/0/7/d/upload/5ec8a40d.png解釋 - 在類別中有一個Prop1,但我想顯示沒有任何類別的Prop1(一個級別向上)。 – 2010-12-01 07:58:45