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. C#
  4. CollectionEditor

CollectionEditor

Scheduled Pinned Locked Moved C#
questioncsharpvisual-studiotutorial
6 Posts 4 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
    Jamie Nordmeyer
    wrote on last edited by
    #1

    How do I open a Collection Editor for a property in code? I know how to open if via the property editor. I want to force it open via code. Obviously it's doable, because VS.NET is doing it in the property editor. Any ideas? Kyosa Jamie Nordmeyer - Cho Dan Portland, Oregon, USA

    C D H 3 Replies Last reply
    0
    • J Jamie Nordmeyer

      How do I open a Collection Editor for a property in code? I know how to open if via the property editor. I want to force it open via code. Obviously it's doable, because VS.NET is doing it in the property editor. Any ideas? Kyosa Jamie Nordmeyer - Cho Dan Portland, Oregon, USA

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      Jamie Nordmeyer wrote: Obviously it's doable, because VS.NET is doing it in the property editor I think that is part of the Visual Studio IDE and not part of the .NET Framework.


      "You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar "On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871)

      1 Reply Last reply
      0
      • J Jamie Nordmeyer

        How do I open a Collection Editor for a property in code? I know how to open if via the property editor. I want to force it open via code. Obviously it's doable, because VS.NET is doing it in the property editor. Any ideas? Kyosa Jamie Nordmeyer - Cho Dan Portland, Oregon, USA

        D Offline
        D Offline
        dacris
        wrote on last edited by
        #3

        Add the Editor attribute to the property, and set it to the type: System.ComponentModel.Design.CollectionEditor I have a symbiotic relationship with my computer.

        H 1 Reply Last reply
        0
        • D dacris

          Add the Editor attribute to the property, and set it to the type: System.ComponentModel.Design.CollectionEditor I have a symbiotic relationship with my computer.

          H Offline
          H Offline
          Heath Stewart
          wrote on last edited by
          #4

          He's asking how you open it, not attribute your collection class/property with one.

          Microsoft MVP, Visual C# My Articles

          1 Reply Last reply
          0
          • J Jamie Nordmeyer

            How do I open a Collection Editor for a property in code? I know how to open if via the property editor. I want to force it open via code. Obviously it's doable, because VS.NET is doing it in the property editor. Any ideas? Kyosa Jamie Nordmeyer - Cho Dan Portland, Oregon, USA

            H Offline
            H Offline
            Heath Stewart
            wrote on last edited by
            #5

            VS.NET provides an implementation of the IWindowsFormsEditorService that UITypeEditors like the various collection editors use. It's not a simple question of just showing the form. First, call TypeDescriptor.GetEditor with either the object or Type for which you want to get the collection editor. Cast that to a UITypeEditor. If not null, call UITypeEditor.EditValue passing an implementation of the IServiceProvider - which you must implement - along with the collection to edit. In your implementation for the IServiceProvider, you must return an instance (could be the same instance) when the IWindowsFormsEditorService is requested, which you would also need to implement. This is what the specific UITypeEditor uses to display its collection editor form.

            Microsoft MVP, Visual C# My Articles

            J 1 Reply Last reply
            0
            • H Heath Stewart

              VS.NET provides an implementation of the IWindowsFormsEditorService that UITypeEditors like the various collection editors use. It's not a simple question of just showing the form. First, call TypeDescriptor.GetEditor with either the object or Type for which you want to get the collection editor. Cast that to a UITypeEditor. If not null, call UITypeEditor.EditValue passing an implementation of the IServiceProvider - which you must implement - along with the collection to edit. In your implementation for the IServiceProvider, you must return an instance (could be the same instance) when the IWindowsFormsEditorService is requested, which you would also need to implement. This is what the specific UITypeEditor uses to display its collection editor form.

              Microsoft MVP, Visual C# My Articles

              J Offline
              J Offline
              Jamie Nordmeyer
              wrote on last edited by
              #6

              Thanks Heath. That did the trick! Kyosa Jamie Nordmeyer - Cho Dan Portland, Oregon, USA

              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