Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 96315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:47:44+00:00 2026-05-10T23:47:44+00:00

I have a non-visual component which manages other visual controls. I need to have

  • 0

I have a non-visual component which manages other visual controls.

I need to have a reference to the form that the component is operating on, but i don’t know how to get it.

I am unsure of adding a constructor with the parent specified as control, as i want the component to work by just being dropped into the designer.

The other thought i had was to have a Property of parent as a control, with the default value as ‘Me’

any suggestions would be great

Edit:

To clarify, this is a component, not a control, see here :ComponentModel.Component

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T23:47:44+00:00Added an answer on May 10, 2026 at 11:47 pm

    [It is important to understand that the ISite technique below only works at design time. Because ContainerControl is public and gets assigned a value VisualStudio will write initialization code that sets it at run-time. Site is set at run-time, but you can’t get ContainerControl from it]

    Here’s an article that describes how to do it for a non-visual component.

    Basically you need to add a property ContainerControl to your component:

    public ContainerControl ContainerControl {   get { return _containerControl; }   set { _containerControl = value; } } private ContainerControl _containerControl = null; 

    and override the Site property:

    public override ISite Site {   get { return base.Site; }   set   {     base.Site = value;     if (value == null)     {       return;     }      IDesignerHost host = value.GetService(         typeof(IDesignerHost)) as IDesignerHost;     if (host != null)     {         IComponent componentHost = host.RootComponent;         if (componentHost is ContainerControl)         {             ContainerControl = componentHost as ContainerControl;         }     }   } } 

    If you do this, the ContainerControl will be initialized to reference the containing form by the designer. The linked article explains it in more detail.

    A good way to see how to do things is to look at the implementation of Types in the .NET Framework that have behaviour similar to what you want with a tool such as Lutz Reflector. In this case, System.Windows.Forms.ErrorProvider is a good example to look at: a Component that needs to know its containing Form.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 234k
  • Answers 234k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Yes, this turns out to be a bug in manifest… May 13, 2026 at 5:54 am
  • Editorial Team
    Editorial Team added an answer I think I've found the answer. The entry-point function should… May 13, 2026 at 5:54 am
  • Editorial Team
    Editorial Team added an answer I would suggest reading Google's Dev Guide on supporting multiple… May 13, 2026 at 5:54 am

Related Questions

I have created a non-visual component in C# which is designed as a placeholder
(More package/component install fun for me -- thanks everyone for all your help to
I have a very simple component which trims all leading and trailing spaces from
Yet another TFrame IDE-registered-component question from me. Thanks for all the help, fellow programmers.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.