We are using a technique similar to what you are asking for.
It's kind of complicated, but you must ensure that you have added your
custom component to the IContainer collection.
The Windows form designer should create a IContainer instance called
components.
Private components As System.ComponentModel.IContainer when the form is
created. When you drop your control onto the System Tray, this component
should be added to the components collection.
For the custom control that you are creating, you need to make sure you have
a Constructor that will take an IContainer instance.
When you drop this control on your form, the Windows Form designer should
call the right construtor passing the components instance.
Me.CustomComponent = New MyCompany.MyProject.CustomComponent(Me.components)
This is the constructor of your CustomComponent.
Public Sub New(ByVal Container As System.ComponentModel.IContainer)
MyBase.New()
InitializeComponent()
'This is the step where your new custom component will be added to the
Container class that is passed in through the constructor.
Container.Add(Me)
End Sub
Then what we have is a WireCustomComponents routine that does the following:
Public Overloads Sub WireCustomComponents(ByVal components As IContainer)
If components Is Nothing = False Then
For Each eComponent As IComponent In components.Components
If TypeOf eComponent Is CustomComponent Then
'Do something with your custom component
'Our component has a Property Named ParentComponentID as String
'You will need to cast the component back to the appropriate type
from the collection.
Dim parentList As String = CType(eComponent,
CustomComponent).ParentComponentID()
End If
Next
End If
> Hi
>
[quoted text clipped - 26 lines]
> Help!
> KK
Ernest Morariu - 28 May 2004 17:16 GMT
Chris,
I am also interested in this subject.
The solution you suggested works fine with the components(the components i
build this way), but you know that, for instance, the class DataAdapter
class do not have constructor taking IContainer parameter, but it still
apears System Tray without being a item in the collection
components.Components.
So, the :
For Each eComponent As IComponent In components.Components
cannot "see" all the object in the SystemTray, but just the ones having a
constructor taking an IComponent parameter.
Did you find any explanation on how these particular objects(like
DataAdapter) are added to the System Tray and what would be the collection
containing them?
Ernest
> We are using a technique similar to what you are asking for.
> It's kind of complicated, but you must ensure that you have added your
[quoted text clipped - 82 lines]
> > Help!
> > KK