As we all know Forms created with Form.cs file
I have property of type Form
example : public Form TargetForm {get;set;}
i don't need to use Activiator.CreateInstance() to create Form I just need to choose a Form from Forms.cs files and attach it with property of TargetForm .
See Screenshot http://prntscr.com/pmuxdd
Tips i guess maybe something usefull to readers : TypeDescriptors, Attributes maybe that return a list of classes in Visual Studio Solutions.
As we all know the ComponentModel API is hard to deal with. so please don't feel bad about that.
There are two services that can help you at design-time to discover and resolve all types in the solution:
ITypeDiscoveryService
: Discovers available types at design time.ITypeResolutionService
: Provides an interface to retrieve an assembly or type by name.In the other hand, to show standard values in a dropdown in property editor, you can create a
TypeConverter
:TypeConverter
: Provides a unified way of converting types of values to other types, as well as for accessing standard values and subproperties.Knowing about above options, you can create a custom type converter to discover all form types in the project and list in the dropdown.
Example
In the following example, I've created a custom button class which allows you to select a form type in design type and then at run-time, if you click on the button it shows the selected form as dialog:
MyButton
FormTypeConverter