Calling my custom editor
-
Hello, I have the following problem: A class with a property called MyCollection which is, obviously, a collection. The collection MyCollection contains items of type MyItemCollection: MyClass property: MyCollection as CustomCollection CustomCollection property: MyItemCollection as SecondCustomCollection Now, I designed custom editors for both "SecondCustomCollection" and "CustomCollection". They both work perfectly, but... When using the collection editor for MyCollection, I click "Add Item" and a new MyCollection item is created. The next step would be to call the editor for the MyItemCollection by pressing a button. That button should programatically call the editor for the second class... This is where I got stuck... Look: cd is the MyItemCollection: Dim tp As Type = cd.GetType ' I get it's type Dim ac As AttributeCollection = t.GetAttributes(tp) ' I get it's attribs Dim ed As EditorAttribute = CType(ac(GetType(EditorAttribute)), EditorAttribute) 'I get the editor If Not ed Is Nothing Then ' found it? Dim te As TypeEditors.ColumnDefCollectionEditor ' this is the editor type te = New TypeEditors.ColumnDefCollectionEditor(GetType ColumnDefinition.ColumnDefinitionCollection)) Now, the logical call to edit the value would be: cd = te.EditValue(context, provider, cd) to launch the editor with the current object and return the same object with the changes. The place I got stuck is finding the context and the provider. Here is what I tried: Dim sv As System.ComponentModel.Design.ServiceContainer = New System.ComponentModel.Design.ServiceContainer() sv.AddService(GetType(IWindowsFormsEditorService), Me) te.EditValue(cd.GetType, sv, cd) But it does not work... I get an error at AddService first of all... So, my question is how can I get the IServiceProvider and the ITypeDescriptorContext required to programatically call my custom editor? Any help would be appreciated! Thank you, Best Regards, Iulian