[Webinar] Streamline your web hosting managementRegister Today


How to open the child form inside the parent form in windows form

Posted on 2010-04-07
Medium Priority
Last Modified: 2013-12-17
My question is that when I click a menu item then a new window opens by virtue of the following code

Form2  f2=new Form2();

Actually this opens the new and separate form.
I want the form should be inside the parent form .That is the new form should not open separately rather it should appear that the new form is embedded in the main parent form. Please see the image attached .

I  do not know the exactly technical term to describe what I want .

so please see the image to understand my query.
Provide me some tutorials or urls or code to implement the actions of the image.
Thanking you

Question by:ANINDYA
  • 2

Expert Comment

ID: 30053143
With what you describe there what you want is instead of a "Form" have it be a custom control.

What happens is on that "panel" you create and add this custom control during runtime.

Basically its treated very similar to a form (design) but its treated like a control (button, text box, etc etc) but lacks the title bar and other independent features that a form has.

Accepted Solution

Tribmos earned 252 total points
ID: 30053242
Found a fairly good guide to get a handle on how to do this

LVL 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 248 total points
ID: 30073981
Good answer by Tribmos.

You can technically use Forms in this manner if you make them borderless and set their TopMost() Property to False.  This allows you to add them to containers just like any other control.

For instance, if you wanted to add your instance of Form2 to a Panel1 you could do:

    Form2 f2 = new Form2();
    f2.TopMost = false;  // won't work without this

You can make the form fill the entire panel by setting its Dock() Property to Fill.

Author Closing Comment

ID: 31712015
Experts if possible please provide me some more urls on the custom control.
Thanks for the suggestions

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that undeā€¦
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
In this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.
Suggested Courses
Course of the Month9 days, 16 hours left to enroll

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question