How to find a parent of the component

  • Thread starter Thread starter Yev
  • Start date Start date
Y

Yev

Hi,
I need to design a custom component (that is i want it to be on the
component tray, not on the form, in the designer), but I also need to
get the form object to which it belongs at runtime. Is it possible to
do it in compact framework?
For the control I could use the Parent property, but component doesn't
have it.
The IContainer and ISite properties of the component dont seem to be
supported for compact framework. Any ideas?

Thanks,
Yev
 
Yev ha scritto:
Hi,
I need to design a custom component (that is i want it to be on the
component tray, not on the form, in the designer), but I also need to
get the form object to which it belongs at runtime. Is it possible to
do it in compact framework?
For the control I could use the Parent property, but component doesn't
have it.

If it does not belong to the form (in the designer is not applied to the
form) why you should can get a parent form?

Maybe you want to apply a .Owner property to your component to old
information about the "linked parent".

Bye
 
Zanna said:
Yev ha scritto:


If it does not belong to the form (in the designer is not applied to the
form) why you should can get a parent form?

Maybe you want to apply a .Owner property to your component to old
information about the "linked parent".

Bye

Actually it does belong to the form. When you drag components on the
component tray in the designer it will generate a code to add them as
instance members of the form which you are designing. But unlike
controls, components will not be added to the Controls collection of
the form.
If i add "Owner" property to my component, that will work, but the
user will have to set this property at run time and i would like to
avoid that.
(That is i want my component's code to find out which form it is on)

Is there a way to find at run time all the forms loaded into an
application?
Then i could use reflection api to find out the one which has my
component.

Thanks,
Yev
 
Back
Top