I derived a class from ICustomTypeDescriptor, and in the GetProperties method I return a PropertyDescriptorCollection collection of CustomProperty. Here is the relevant part of my CustomProperty class: (i know it's a bit crude, but everything else works including the DateTime picker)
ref class CustomProperty : PropertyDescriptor
{
String^ cat;
String^ name;
String^ data;
int type;
String^ instr;
public:
CustomProperty(String^ c, String^ n, String^ d, String^ i, int t): PropertyDescriptor(n, nullptr),cat(c),name(n),data(d),type(t),instr(i) {}
virtual Object ^GetValue(Object ^component) override
{
switch (type) {
case 1:
return UInt32::Parse(data);
case 2:
return gcnew DateTime(2010,8,UInt32::Parse(data));
default:
return data;
}
}
virtual property Type ^PropertyType
{
Type ^ get() override {
switch (type) {
case 1:
return UInt32::typeid;
case 2:
return DateTime::typeid;
case 3:
return Windows::Forms::Design::FileNameEditor::typeid;
default:
return String::typeid;
}
}
}
virtual property String ^Category
{
String^ get() override {return cat; }
}
virtual property String ^Description
{
String^ get() override {return instr; }
}
.
.
.