Re: Equivalent to VCL's DataModule



Clive Dixon wrote:
Can any component derived class serve as a container for other
components if it implements System.ComponentModel.Component's constructor which takes a System.ComponentModel.IContainer as a parameter ?

Further to my previous answer, I think I might be misunderstanding what you are getting at.

If I create a component class in VS, it will generated with:
1) a constructor taking IContainer and calling IContainer.Add(IComponent), so that if you for example drag drop your component onto a form (which is generated by VS containing a Container object), VS ensures that your component will be added to the form's Container object.
2) a private variable of type Container which may be used as the container for other components you drag drop onto your component. Likewise, VS will add that other component to your component's container only if that other component has a constructor taking IContainer (and that constructor would have to call IContainer.Add(IComponent) to work correctly).

Thanks for the explanation.

Does the IDE know to look for a private variable of type System.ComponentModel.Container in a CLR object in order to have that object act as a container for other objects at design time ? If not, what is the criteria by which an object at design time can act as a visual container of other objects ?

.



Relevant Pages

  • Re: pointers to elements in containers
    ... The 'key_fields' container is meant to store pointers to the ... so Detail's constructor looks like the ... pointers to elements in 'fields' point to valid ... Is your Detail struct being copied? ...
    (microsoft.public.vc.language)
  • Re: default values - the good, the bad and the ugly
    ... > The thing is that in your tale, they didn't change only a constructor ... In the specific case the someClass is a container of ... geometric curves, 'd' is the c0 continuous tolerance between ... the capacity reserved would be double the last size. ...
    (comp.lang.cpp)
  • pointers to elements in containers
    ... The 'key_fields' container is meant to store pointers to the std:string's in ... locations only until the end of the constructor after which they change (if ... Addresses of the elements in a vector may change after resize(), ...
    (microsoft.public.vc.language)
  • Re: Equivalent to VCLs DataModule
    ... System.ComponentModel.Container in a CLR object in order to have that object act as a container for other objects at design time? ... that the class derives either from Form or Component, though I don't know for sure. ...
    (microsoft.public.dotnet.framework)
  • Re: [std::vector] operator[], the heap and try-carch blocks
    ... However, if the container contains ... You should be able to get away without their use by setting data members to ... complicated resource acquisition in the constructor body. ... thereby allowing you to complete object construction ...
    (alt.comp.lang.learn.c-cpp)