Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Calling my custom editor

Calling my custom editor

Scheduled Pinned Locked Moved Visual Basic
helpquestiondesign
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Julusian
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups