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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. ComponentModel documentation [solved]

ComponentModel documentation [solved]

Scheduled Pinned Locked Moved .NET (Core and Framework)
tutorialcsharpdesignquestion
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.
  • V Offline
    V Offline
    vtchris peterson
    wrote on last edited by
    #1

    I'm trying to create a Component that sits in the Forms designer component tray and contains additional subcomponents that can be selected and configured via the document outline view (or through a collection property of the main component). I've looked at numerous code project articles and even peeking at some MS components that behave kind of like this (e.g. ListView), but I can't seem to get my sub-components to show up in the Document Outline. The MSDN is non-helpful in this area, their "documentation" consists of is a 2 sentence blurb describing an esoteric example and then 10 pages of code that assumes an intimate understanding of the entire .NET component model. Anyone know of a good source of documentation on this area, or better yet any tips on what I might try? Thanks, -Chris [solved] I figured out how to do it. In my main component, add a custom designer:

    [Designer(typeof(MyDesigner), typeof(IDesigner))]
    public class MyComponent : Component

    Then in MyDesigner, inherit from System.ComponentModel.Design.ComponentDesigner and override a couple methods, shown below:

      public override void Initialize(IComponent component)
      {
         base.Initialize(component);
    
         \_myComponent = (MyComponent) component;
      }
    
      public override System.Collections.ICollection AssociatedComponents
      {
         get
         {
            if (\_myComponent == null)
            {
               return base.AssociatedComponents;
            }
            return \_myComponent.Subcomponents;
         }
      }
    

    Now my sub components are selectable via Document Outline, but suppressed in the component tray (so as to keep it tidy). :cool:

    modified on Friday, December 4, 2009 11:57 AM

    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