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
[quoted text, click to view] "KK" <kk@kk.com> wrote in message
news:OhIYhjUQEHA.3452@TK2MSFTNGP10.phx.gbl...
>
>
> Hi
>
> I am developing a user control and for that
> I need to query the component tray controls
> to find out wether there are any controls
> such as errorProvider added to the project.
>
> If so, I have to list them in my user controls
> property browser. The problem is that
> I couldn't found any information on querying
> the components added to ComponentTray.
>
> Couple of hints I receievd was to query the
> Site of a control and iterate its container.
> Which I have trided but alway returns null.
>
> Have any body tried doing this and
> got positive results?
>
> Note: I dont want to query the component
> variable which gets added to the form. What
> I want is to QUERY all the compoents added
> to COMPONENT TRAY.
>
> I know, I have to do some meddling with
> Design time support, but the help avialable
> is extremely limited.
>
> Help!
> KK
>
>