Finding a Component's (ComponentModel.Component) Parent Form

J

JackRazz

I'm working on a .net component (not a control) and need to find out what form the
component is contained in during runtime (DesignMode=False). With a control, there
is a parent property (and FindForm) to do this with, but no such luck with a
component.

I was thinking that I might be able to iterate thru the Container.Components with
something like this with the Site.Name being the components name. This assumes that
a form is added to the container.components.

Dim c As IComponent
For Each c In Me.Container.Components
Console.WriteLine(c.Site.Name)
Next

But this doesn't seem to work. Does anyone have any idea as to how I can determine
what form a component is placed on??

Thanks - JackRazz
 
J

John Saunders

JackRazz said:
I'm working on a .net component (not a control) and need to find out what form the
component is contained in during runtime (DesignMode=False). With a control, there
is a parent property (and FindForm) to do this with, but no such luck with a
component.

I was thinking that I might be able to iterate thru the Container.Components with
something like this with the Site.Name being the components name. This assumes that
a form is added to the container.components.

Dim c As IComponent
For Each c In Me.Container.Components
Console.WriteLine(c.Site.Name)
Next

But this doesn't seem to work. Does anyone have any idea as to how I can determine
what form a component is placed on??

What about your components Site property? It has a Container property (as
well as a DesignMode property).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top