Is it possible to modify a ComponentConverter
, Typeconverter
,... so I can select "Components" that are in a static class outside the form?
When I create a custom control and add a property of type Component
or Control
I get a dropdown menu in designer where I can select one ot the existing ones.
The reference to the selected object is automatically added in the designer code.
Problem is, that the dropdown only lets me select components that were declared in this form or a form that this form inherits, but no other form or a static class.
But I want to have one specific file in my solution where I can declare all these components once, an then use them in each form (I have several in my project) at designtime.
When I add the reference to the static objects myself in designer code, everything works fine, but this is not comfortable, because I have to alter the code manually.
Would it be possible to modify a Converter
or UITypeEditor
, so it can select static objects and then pass them to the designer?
I tried to override a ComponentConverter, but in the designer code it only writes "null" instead of the object:
class MyConverter : ComponentConverter
{
public MyConverter(Type type) : base(type)
{
}
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
return new StandardValuesCollection(new List<BOOL>() { Variablen.M0_2, Variablen.M0_3, Variablen.M0_4 });
}
}
After some work, I got this working, but stability is not the best. Sometimes after compiling I get errors, because context or service is null in the
TypeConverter
Base-class:
Serializer:
Container
TypeConverter