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

Discussion in 'ASP .Net Building Controls' started by JackRazz, Mar 4, 2004.

  1. JackRazz

    JackRazz Guest

    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
     
    JackRazz, Mar 4, 2004
    #1
    1. Advertising

  2. "JackRazz" <> wrote in message
    news:%...
    > 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).
    --
    John Saunders
    John.Saunders at SurfControl.com
     
    John Saunders, Mar 4, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?QVNQIERldmVsb3Blcg==?=

    System.ComponentModel.DefaultValue doesn't work with user control

    =?Utf-8?B?QVNQIERldmVsb3Blcg==?=, Sep 13, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    1,682
    =?Utf-8?B?QVNQIERldmVsb3Blcg==?=
    Sep 13, 2006
  2. Replies:
    0
    Views:
    479
  3. shahin
    Replies:
    0
    Views:
    475
    shahin
    Aug 30, 2007
  4. WebGyver
    Replies:
    0
    Views:
    508
    WebGyver
    Feb 4, 2008
  5. Nathan Sokalski
    Replies:
    2
    Views:
    2,943
    bruce barker
    Jan 27, 2009
Loading...

Share This Page