Hi all! I have a form with controls and non-visual components. Some of them implements interface MyInterface and some have a MyInterface Property.
Task is : select MyIntrerface Property for control in property grid from all components that implement MyInterface.
Descibe code:
I wrote a typeconverter to perform string <=> MyInterface types conversation:
I have:
MF == null
but
_myComponent.Pa rentForm is MainForm
but
ComponentParent Form is Form
!! ComponentParent Form is not MainForm !!
ComponentParent Form.Name == "MainForm"
How i can get ComponentParent Form with MainForm type ?
Task is : select MyIntrerface Property for control in property grid from all components that implement MyInterface.
Descibe code:
Code:
interface MyInterface {}
public class ControlClass : UserControl
{
MyInterface MyInterfaceProvider {get; set;}
}
public class ComponentClass : Component, MyInterface{}
public class MainForm:Form
{
ControlClass _myControl;
ComponentClass _myComponent;
[...]
}
Code:
public class InterfaceTypeConverter: TypeConverter{
public override
StandardValuesCollection GetStandardValues(
ITypeDescriptorContext context){
[...checks]
// try to obtain ParentForm for getting _myComponent;
ComponentParentForm = (context.Instance() as _myControl).ParentForm;
MainForm MF = ComponentParentForm as MainForm;
[...]
}
[...]
}
MF == null
but
_myComponent.Pa rentForm is MainForm
but
ComponentParent Form is Form
!! ComponentParent Form is not MainForm !!
ComponentParent Form.Name == "MainForm"
How i can get ComponentParent Form with MainForm type ?
Comment