【发布时间】:2011-08-11 14:56:59
【问题描述】:
目前我有一个 A 类型的对象,PropertyGrid 正在查看它。但是,它的属性之一是类型 B。类型 B 的属性是不可扩展的。我怎样才能改变这个:
a) 我可以扩展自定义对象属性的 b) 这些更改绑定到该属性
这是我目前的代码:
using System;
using System.Windows.Forms;
using System.ComponentModel;
namespace PropGridTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
A a = new A
{
Foo = "WOO HOO!",
Bar = 10,
BooFar = new B
{
FooBar = "HOO WOO!",
BarFoo = 100
}
};
propertyGrid1.SelectedObject = a;
}
}
public class A
{
public string Foo { get; set; }
public int Bar { get; set; }
public B BooFar { get; set; }
}
public class B
{
public string FooBar { get; set; }
public int BarFoo { get; set; }
}
}
【问题讨论】:
标签: c# view propertygrid expand