Custom Component that contains Components

DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Custom Component that contains Components

  1. #1
    Join Date
    Jul 2010

    Question Custom Component that contains Components

    I'm using vb2010.
    I have a component (ActionsManager) with a Collection of components (ActionHandler) property. I want the ActionsManager to be the Container for ActionHandlers, not the Form. And in the Document Outline window, ActionHandlers to be displayed under the ActionsManager, like controls under the Form. How can i do this?

    Thank's in advance!

  2. #2
    Join Date
    Feb 2004
    Longueuil, Québec
    The Document outline provides a way to see the relation between a Container control and its child controls. It has been designed to show the hierarchy between controls, not components.

    Since a Component is not a Container, neither a Control, you cannot use it to do what you want to do.

    In order to see a hierarchy between your 2 classes in the Document Outline, ActionsManager needs to be a Control that has been designed as a container, either by inheriting from a Control that is already a Container (creating a UserControl instead of a Component might be the easiest solution here), or by implementing the IContainerControl interface (if you know what an interface is).

    Then, ActionHandler should be a Control.

    Since they are designed as controls, they will appear on the Form instead of in the components tray. You would simply have to drag the ActionHandlers onto the ActionsManager, and then maybe set the ActionsManager to a size of 0,0 so that it does not show on the form. That would not be a very good design idea, since a Control is usually something that is visible, but it would enable you to do what you want, simply by adding the a
    Jacques Bourgeois

  3. #3
    Join Date
    Jul 2010
    Thanks for your reply, but i solved my problem just right now.

    I have remove the contructor created by designer
    "'<System.Diagnostics.DebuggerNonUserCode()> _
    'Public Sub New(ByVal container As System.ComponentModel.IContainer)
    ' MyClass.New()

    ' 'Required for Windows.Forms Class Composition Designer support
    ' If (container IsNot Nothing) Then
    ' container.Add(Me)
    ' End If

    'End Sub"

    And i create a Designer for ActionsManager:

    Imports System.ComponentModel.Design

    Public Class ActionsManagerDesigner
    Inherits ComponentDesigner

    Public Overrides ReadOnly Property AssociatedComponents As System.Collections.ICollection
    Dim manager As ActionsManager = CType(Me.Component, ActionsManager)
    If manager Is Nothing Then Return MyBase.AssociatedComponents
    Dim controls As New ArrayList()
    Return controls
    End Get
    End Property
    End Class

    When i create an ActionHander object i'm adding this to ActionManager Components.

    I've got exactly what i want.

Similar Threads

  1. Custom List component for MIDP
    By wrappingduke in forum Mobile
    Replies: 0
    Last Post: 02-02-2009, 04:24 PM
  2. Replies: 0
    Last Post: 01-17-2007, 11:38 PM
  3. Replies: 0
    Last Post: 12-11-2002, 07:05 PM
  4. Custom GUI Component
    By guy in forum Java
    Replies: 0
    Last Post: 08-27-2000, 08:56 AM
  5. designing custom swing components?
    By Lim Wing Hoe in forum Java
    Replies: 0
    Last Post: 07-16-2000, 05:49 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center