On Jan 22, 1:55*pm, Peter Duniho <no.peted.s...@no.nwlink.spam.com>
wrote:
> Mike wrote:
> > On Jan 22, 1:24 pm, "Herfried K. Wagner [MVP]" <hirf-spam-me-
> > h...@gmx.at> wrote:
> >> Am 22.01.2010 16:52, schrieb Mike:
>
> >>> Is there a way to detect when the parent of a control is about to
> >>> change? I am aware of the ParentChanged event but that happens too
> >>> late. I don't see any ParentChanging event.
> >> Why exactly does it happen too late? *What do you want to achieve?
>
> >> --
> >> * M S * Herfried K. Wagner
> >> M V P *<URL:http://dotnet.mvps.org/>
> >> * V B * <URL:http://dotnet.mvps.org/dotnet/faqs/>
>
> > There is some clean up work that I need to do before the control is
> > removed. If I wait for the ParentChanged event, the parent will be
> > null and I get errors.
>
> AFAIK, you can't get the notification you want.
>
> Without more specifics, it's unclear as to what details you have that
> are dependent on the parent, nor why you're not able to rely on the code
> that is actually changing the parent. *These may or may not be design
> problems.
>
> But purely from the practical side of things, it seems that you will
> need to retain a reference to the parent control elsewhere, so that you
> still have access to it after the Parent property changes.
>
> Pete- Hide quoted text -
>
> - Show quoted text -
Saving the property elsewhere does not solve my problem since the
object that looks for the parent is in a 3rd party assembly. Anyway,
thanks for the answer to the original question. I will have to see if
I can find a different approach.
|