基本クラス(ノード)といくつかの継承されたタイプがあります。
Class Node
{
Base_Attributes...
}
Class Derived : Node
{
Derived_Attributes...
}
これらのタイプは、プロジェクトに追加したdllに含まれています。そして、その属性の1つがNodeであるというItemというクラスがあります。私は次のようにitmeのプロパティを表示するPropertygridを持っています:
Class Item
{
Point location;
String name;
Node quiddity;
bool[] IsBrowsable;
public Point Location{set;get;}
public String Name{set;get;}
public String NodeAttrib{set;get;}
[Browsable(IsBrowsable[thisindex])]
public String DerivedTypeAttribe{set;get;}
[Browsable(IsBrowsable[otheroneindex])]
public String DerivedTypeAttribe{set;get;}
Item(string type)
{
switch(type)
{
case"some":
Node = new derived_some();
IsBrowsable[thisindex] = true;
break;
}
}
}
そしてメインフォームのどこか:
propertygrid.selectedobject = item;
ここでの問題は、派生型に指定されたいくつかのプロパティがあり、それらをpropetygridに表示する必要がありますが、ノードの型は実行時まで不明です。ブール値の配列を使用してBrowsabl()属性を設定しようとしましたが、BrowsableParameterは定数値である必要があることがわかりました。どのように私はこれを渡すことができますか?